4

I have a data set in which I converted all "~" values to blank spaces "", and when I use the View() function to view the data set, I can clearly see the blank spaces. However, after I save my modified data frame as a .csv file via write.csv and read it again in R via read.csv, all the blank spaces are somehow changed to NA values. I tried to change all my NA values back to the blank spaces again, but the same problem occurs when I save as csv and read it again.

Any help would be appreciated!

joran
  • 169,992
  • 32
  • 429
  • 468
user3755880
  • 375
  • 1
  • 5
  • 14
  • would you please post sample data and code that reproduces the problem? the answer probably has to do with your `na.strings` in `read.csv` or your `na` in `write.csv`, or possibly whether the values are characters or factors, but there's no way to know for sure. – C8H10N4O2 Jun 24 '15 at 20:11

1 Answers1

2

there is the parameter na you can specify

write.csv(data, "data.csv", row.names=FALSE, na="")

When you read it again you need to convert NA to blank everytime though

data[is.na(data)]<-""
RDGuida
  • 546
  • 4
  • 15