[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 04:11:22 CET 2009


it works perfectly!!!! thank you for your help....

what if i want to seperate each stations data and save in a .csv file??
while i'm asking you these i'm also finding some ways to do so..

thank you again.





jholtman wrote:
> 
> try using:
> 
> data.info <- rbind(data.info, cbind(station.id, year, date,
> max.discharge))
> 
> On Tue, Feb 17, 2009 at 9:26 PM, CJ Rubio <cjrubio at kongju.ac.kr> wrote:
>>
>> 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.
>>
>> ______________________________________________
>> R-help at 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.
>>
> 
> 
> 
> -- 
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390
> 
> What is the problem that you are trying to solve?
> 
> ______________________________________________
> R-help at 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.
> 
> 

-- 
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-tp22070942p22071324.html
Sent from the R help mailing list archive at Nabble.com.




More information about the R-help mailing list