HNSKD
HNSKD

Reputation: 1644

Imported CSV into R, Missing Values Become "" instead of NA

I tried this command

df<-read.csv("filename.csv",stringsAsFactors=FALSE)

For both, num and int variables, missing values are read as NA. However, for chr, missing values are read as "" instead. When I take the command is.na(""), it returns a FALSE. How do I rectify this?

I tried: str(replace,"",NA"), but it would not work.

Upvotes: 1

Views: 84

Answers (1)

tobiasegli_te
tobiasegli_te

Reputation: 1463

Check out ?read.csv, especially the argument na.strings.

Upvotes: 2

Related Questions