Hi Rich, It's not obvious what would be causing that error from read.csv. But here's what I would probably try:
Add quote='"" to your arguments. The default is to use surround text strings with double quotes, but your file doesn't. Copy the first few rows into another file and try it. If it succeeds, that would suggest something later on in the file is causing the problem. The argument sep=',' is redundant for read.csv. In other words, it sets sep for you. I'd try switching to the more general read.table. Are the NAs in the file indicated by NA between a pair of commas? Or do you have successive commas with nothing between them for NA? Not sure what difference it will make, but it might affect what args you pass to read.table. Are you absolutely sure there are never any commas in the name? -Don -- Don MacQueen Lawrence Livermore National Laboratory 7000 East Ave., L-627 Livermore, CA 94550 925-423-1062 Lab cell 925-724-7509 On 8/17/18, 3:08 PM, "R-help on behalf of Rich Shepard" <r-help-boun...@r-project.org on behalf of rshep...@appl-ecosys.com> wrote: I have a data file, 'precip_projected.csv,' that starts like this: name,easting,northing,elev,sampdate,prcp Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-01,0.59 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-02,0.08 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-03,0.1 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-04,0 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-05,0 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-06,0.02 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-07,0.05 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-08,0.1 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-09,0 Headworks Portland Water,2370575.38427211,199337.634652112,228,2005-01-10,0.02 There are a bunch of NAs in the data file. The command to read it produces an error: rainfall <- read.csv('../data/precipitation/precip_projected.csv', header = T, sep = ',', as.is = T) Error in `$<-.data.frame`(`*tmp*`, date, value = numeric(0)) : replacement has 0 rows, data has 113569 Is the error generated by finding a date that looks like the number zero or by a prcp value of zero? BTW, I get the same error if I specify stringsAsFactors = F. TIA, Rich ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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. ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.