[R] read.csv() error

Rich Shepard r@hep@rd @end|ng |rom @pp|-eco@y@@com
Thu Sep 2 18:32:24 CEST 2021


The first three commands in the script are:
stage <- read.csv('../data/water/gauge-ht.dat', header = TRUE, sep = ',', 
stringsAsFactors = FALSE)
stage$sampdate <- as.Date(stage$sampdate)
stage$ht <- as.numeric(stage$ht, length = 6)

Running the script produces this error:
> source('stage.R')
Error in `$<-.data.frame`(`*tmp*`, ht, value = numeric(0)) :
   replacement has 0 rows, data has 486336

Sample lines from the data file:
sampdate,samptime,elev
2007-10-01,01:00,2.80
2007-10-01,01:15,2.71
2007-10-01,01:30,2.63
2007-10-01,01:45,2.53
2007-10-01,02:00,2.45
2007-10-01,02:15,2.36
2007-10-01,02:30,2.27
2007-10-01,02:45,2.17
2007-10-01,03:00,2.07

Maximum value for elev is about 11.00, 5 digits.

I don't understand this error because the equivalent commands for another
data source file completes without error.

What is that error message telling me?

TIA,

Rich



More information about the R-help mailing list