creating a new column from recoding a column in a data frame

Please I need help with this, I keep getting errors.
Will be glad to have another way of doing it too. Thank you.

data<-data[, -c(6,14,17,19,20)]
clean_data <- data[complete.cases(data),]
#View(clean_data)
clean_data <- within(clean_data, {
WHO <- NA
WHO[clean_data$Pango lineage== B.1.1.7] <- "ALPHA" WHO[clean_data$Pango lineage== B.1.427] <- "EPSILON"
WHO[clean_data$Pango lineage== B.1.525] <- "ETA"
WHO[clean_data$Pango lineage== P.3] <- "THETA"
WHO[clean_data$Pango lineage== B.1.617.1] <- "KAPPA"
WHO[clean_data$Pango lineage== B.1.526] <- "IOTA"
WHO[clean_data$Pango lineage== P.2] <- "ZETA"
WHO[clean_data$Pango lineage== B.1.621] <- "MU" WHO[clean_data$Pango lineage== C.37] <- "LAMBDA"
WHO[clean_data$Pango lineage==B.1.351]<-"BETA"
WHO[clean_data$Pango lineage==P.1]<-"GAMMA"
})

We don't have the data, and you didn't tell us what the errors are, so it's hard to help. Could you provide a minimal reproducible example, as described here:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.