I am looking to apply an if else statement for each row in a dataset for a specific column in R. I want to have it loop through every row and check the value in a certain column to be greater or less than 150, and then assign a 1 or a 0 in a new column based on this. Below is the code that I am currently working with, when run however, only 0's are returned.
for(i in 1:nrow(RawData)){
RawData[i, 5] <-
if(RawData$users <= 150) {
1
} else {
0
}
}
head(RawData)
Any advice would be great, Thanks!