I'm not sure why this is so difficult, but I simply want to return the data in rowX,colB when rowX,colA is > 70.
df
colA colB
80 6
75 7
60 5
66 4
vector <- ifelse(df$colA > 70, paste0('above 70', df$colB), 'below 70')
The result is a vector with 'below 70' if below 70 and NA if above 70, but why? Even if the ifelse statement doesn't understand the row for df$colB it should never return NA as paste0('above 70', df$colB) is actually a dataframe. Is the ifelse statement blind to the row number it's evaluating outside of the first conditional statement?
Aucun commentaire:
Enregistrer un commentaire