I have a table where I have a numerical column of whole positive and negative values. I am trying to run a simple if statement where if the value of Yds is less than 10, then a brand new numerical column (Ydsle10) gets a 1 else a 0
Here is my code:
Data$Ydslt10 <- if(Data$Yds < 10) {Data$Ydslt10 <- 1} else {Data$Ydslt10<-0}
Here is the error:
the condition has length > 1 and only the first element will be used
str of my table is:
$ Name : Factor w/ 206 levels "A.Abdullah","A.Boldin",..: 68 199 79 120 120 79 68 27 68 150 ...
$ Team : Factor w/ 31 levels "ARI","BAL","BUF",..: 9 9 9 4 4 9 9 9 9 4 ...
$ Position : Factor w/ 3 levels "RB","TE","WR": 3 2 3 3 3 3 3 1 3 1 ...
$ Yds : num 0 10 4 17 14 14 7 2 6 -3 ...
$ Receptions: num 1 1 1 1 1 1 1 1 1 1 ...
$ Targets : num 1 1 1 1 1 1 1 1 1 1 ...
$ Ydslt10 : num 1 1 1 1 1 1 1 1 1 1 ...
$ Ydsgt10 : num 0 0 0 0 0 0 0 0 0 0 ...
I cannot seem to figure out the error, and web searches have not been too helpful.