Odp: How to replace all <NA> values in a data.frame with another ( not 0) value
Hi r-help-bounces at r-project.org napsal dne 04.05.2010 14:54:14:
I need to replace <NA> occurrences in multiple columns in a data.frame with "000/000"
Be careful if you replace NA in numeric columns.
str(test)
'data.frame': 10 obs. of 3 variables: $ mp: num 20.9 19.9 20.1 20.2 18.9 ... $ so: num 18.8 18.6 18.2 17.9 18.1 ... $ le: num 48 49.1 48.8 42.6 46.1 ...
test[2,2] <- NA test[is.na(test)] <- "000/000" str(test)
'data.frame': 10 obs. of 3 variables: $ mp: num 20.9 19.9 20.1 20.2 18.9 ... $ so: chr "18.75" "000/000" "18.25" "17.89" ... $ le: num 48 49.1 48.8 42.6 46.1 ...
numeric column is now character and you can not use it for further analysis without some fiddling around. Regards Petr
how do I achieve this? Thanks Nevil Amos
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.