I want all NAs to be replaced with "Not Found" in a df .
i have this df
A B
1 NA
2 NA
3 NA
How can i get that .
A B
1 Not Found
2 Not Found
3 Not Found
I want all NAs to be replaced with "Not Found" in a df .
i have this df
A B
1 NA
2 NA
3 NA
How can i get that .
A B
1 Not Found
2 Not Found
3 Not Found
You can Assign "Not Found" to df[is.na(df)]
. However, it will cause errors if some columns are factors.
df <- data.frame(A = 1:3, B = rep(NA, 3), stringsAsFactors = FALSE)
df
# A B
# 1 1 NA
# 2 2 NA
# 3 3 NA
df[is.na(df)] <- "Not Found"
df
# A B
# 1 1 Not Found
# 2 2 Not Found
# 3 3 Not Found