[R] rbind: number of columns of result is not a multiple of vector length (arg 1)

CJ Rubio cjrubio at kongju.ac.kr
Wed Feb 18 03:26:57 CET 2009


i have the following constructed and running very well,, thanks to Gabor
Grothendieck for his help.

>data.info <- c("station.id", "year", "date", "max.discharge")
>
> for(i in 1:num.files) {
+ station.id <- substring(data[i], 1,8)
+ DF <- read.table(data[i], sep=",", blank.lines.skip = TRUE)
+ z <- zoo(DF[,4], as.Date(as.character(DF[,3]), "%m/%d/%Y"))
+ f <- function(x) time(x) [which.max(x)]
+ ix <- tapply(z, floor(as.yearmon(time(z))),f)
+ year <- (1988:2005)
+ date <- time(z[ix])
+ max.discharge <- coredata(z[ix])
+ data.info <- rbind(data.info, c(station.id, year, date, max.discharge))
+ }

my problem with my code occurs in the part where I arrange my results..
after running this code, i get this warning:

Warning message:
In rbind(data.info, c(station.id, year, date, max.discharge)) :
  number of columns of result is not a multiple of vector length (arg 1)


i can't figure out what to do to produce the result i wanted:
(for each station, it should look like this:)

data.info     "station.id"     "year"       "date"      "max.discharge" 
                   "01014000"     1988   "1988-11-07"       4360 
                   "01014000"     1989   "1989-05-13"     20000  
                   "01014000"     1990   "1990-10-25"       9170
                   "01014000"     1991   "1991-04-22"     12200
                   "01014000"     1992   "1992-03-29"     11800
                    ....
                   "01014000"     2005   "2005-04-04"     22100

thanks in advence for your help..
-- 
View this message in context: http://www.nabble.com/rbind%3A-number-of-columns-of-result-is-not-a-multiple-of-vector-length-%28arg-1%29-tp22070942p22070942.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list