mardi 21 septembre 2021

adding a column using if statement

For the blow sample data, I am trying to use the if statement to create a new column called newcol. I would like to condition the newcol on the Letter column such that if the Letter is NA then newcol is TRUE. How can I do this using if command without loading any libraries?

Thanks,

MRR

    M <- data.frame(c("A","B","C",NA),c(5,100,NA,60))

names(M) <- c("Letter","Number")

Aucun commentaire:

Enregistrer un commentaire