I have used the same method for replacing NA's with blanks or other characters but for some reason this one is not working. I want to replace the NA's on my dataframe to blanks (columns year and Annual). What am I doing wrong?
shad.92 <- structure(list(year = c(1992, NA, NA, NA, NA), type = c("all age abundance index",
"adjusted number of fish older than age 0 measured", "adjusted total number of fish measured",
"percent YOY", "YOY abundance index"), September = c(755, 0,
565, 100, 755), October = c(530, 0, 434, 100, 530), November = c(463,
0, 338, 100, 463), December = c(266, 1, 136, 99.3, 264), Annual = c(2014,
NA, NA, NA, 2012)), row.names = c(NA, -5L), class = c("tbl_df",
"tbl", "data.frame"))
I tried this with no luck:
shad.92 <- shad.92[is.na(shad.92)] <- ""
I then tried one column at the time starting with year:
shad.92$year <- as.character(shad.92$year)
shad.92$year[is.na(shad.92$year)] <- " "
shad.92
But I get quotation marks instead of blanks ("")
' '
, it converts to character – Ironic