[r] R multiple conditions in if statement

I have read many of the if statement posts but have not been able to find an answer to my simple problem. I would like to create a new column in the data frame 'tester' based on a multiple condition if statement.

tester<- as.data.frame(matrix(data=c(seq(1,300,by=1.5)), ncol=4))

if (tester$V3> 200 && tester$V4>250){tester[,5] <- "one"} else tester$V5 <-NA

This gives me NAs for the entire column even though the last 17 rows are TRUE for both cases and should be "one". What is happening here? Thank you for your help!

This question is related to r if-statement

The answer is


Read this thread R - boolean operators && and ||.

Basically, the & is vectorized, i.e. it acts on each element of the comparison returning a logical array with the same dimension as the input. && is not, returning a single logical.