Dear R-users, I have a large data file that I am trying to read in R where the file has a white space at the begging and at random places. The whitespace is actually NA so I am trying to read the file using scan but with no success!! Please help
Here are some example rows from the data file. 1 1 0 0 2 1 1 0 0 2 1 21 0 2 180 64.5 19.9 0.8 54.5 1.86 133.3 0 1 1 0.6 0.6 0 0 0 Yes the whitespace is NA so with someone help it should look like NA 1 1 0 0 2 NA 1 1 0 0 2 1 21 0 2 180 64.5 19.9 0.8 54.5 1.86 133.3 NA 0 NA NA Here is my code test <-scan(“DATA",nlines=9,strip.white=F,blank.lines.skip=F,sep=",",what="") dput(test) c(" 1 1 0 0 2 1 1", " 0 0 2 1 21 0 2 180 64.5", " 19.9 0.8 54.5 1.86 133.3 0 ", " 1 1 0.6 0.6 0 0 0", " 2 1 21 0 2 180 64.5", " 19.9 0.8 54.5 1.86 133.3 0 ", " 1 1 1.1 1.1 3.2 0 0", " 2 1 21 0 2 180 64.5", " 19.9 0.8 54.5 1.86 133.3 0 " ) I tried to use na.string="[[:space:]]+$" with no luck. Thanks, John [[alternative HTML version deleted]]
______________________________________________ R-help@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.