From a given data frame with a column State which has values P or F I am trying to create another column State1 which will have values 1 or 0 depending on whether State is P or F. The following is the code I wrote
for(i in 1:nrow(df)){
if (df$State(i)==P) {df$State1(i)<- 1}
else {df$State1(i) <- 0}
}
However I keep getting the error "attempt to apply non function". My code seems very simple and I am not sure why I am getting non function error. Please help Thanks KS
df$State(1)- what does it give you?