0

I am new to R programming. I have been using the data.table package, specifically fread, to import a file from a website. The file is type csv. The file has a lot of junk in it. What is causing an issue for me are the fields with " ". I've tried a variety of ways to coax the " " to NA, but haven't had luck. I did find this relevant posting:

Blank space not recognised as NA in fread

I modified fread to say:

data6<-fread("https://data.colorado.gov/resource/8jg4-bud5.csv", na.strings = c("", "NA")) and did see a lot of improvement with "".

Please help me address the issue in the file with " " or provide a workaround to change this to NA. I've tried a host of ways with no luck.

(I process the NA's later in the data cleansing phase).

You can download the file and modify it with - data6<-fread("https://data.colorado.gov/resource/8jg4-bud5.csv", na.strings = c("", "NA")).

David Arenburg
  • 91,361
  • 17
  • 137
  • 196
kffont
  • 11
  • 3
  • At first glance, adding a `" "` to your `na.strings` seems to be filling all values with NA that were otherwise empty. Does that provide intended behavior? – caw5cv Aug 01 '18 at 14:20
  • I resolved the issue with: S<-" ", v<-which(data6[]==S, arr.ind=TRUE), data6[v]<-0 – kffont Aug 01 '18 at 18:25
  • caw5cv, the option of adding " " to na.strings doesn't work unfortunately. Thanks for your input! – kffont Aug 01 '18 at 18:28

0 Answers0