Replace NA values by string "Unknown" in R -


i have list x contains 12 months in year. in data, have column y has following levels: "done", "not done" , "". want replace "" string "unknown".

i tried:

for (i in 1:length(x)) {    x[[i]]$y[which(is.na(x[[i]]$y))] == "unknown" } 

i error:

"error: unexpected input in " plist15[[i]]$ib.opportunity.type[which(is.na(plist15[[i]]$ib.opportunity))] == "unknown"

you don't need loop this, can like:

# data `""` v <- 1:10 v[c(3,5,8)] <- "" v  [1] "1"  "2"  ""   "4"  ""   "6"  "7"  ""   "9"  "10"   v[v == ""] <- "unknown"   [1] "1"       "2"       "unknown" "4"       "unknown" "6"       "7"       "unknown" "9"       "10" 

Comments

Popular posts from this blog

java - pagination of xlsx file to XSSFworkbook using apache POI -

Unlimited choices in BASH case statement -

apache - How do I stop my index.php being run twice for every user -