[R] Data.frames with different line's length

From: Joćo Mendes Moreira <jmoreira_at_fe.up.pt>
Date: Tue 21 Jun 2005 - 21:09:21 EST


Hello,

I want to create a data.frame with different number of columns per line. What I want is something like:

example <- NULL
begin <- 1
while (end < nrow(orig.data))
{
end <- next.day(orig.data,begin) # my own function. It returns the first index from the next day. Each day has a different number of records. example <- rbind(example, c(begin, end, predictions[c(begin:end)], ...)) begin <- end+1
}

It gives the following warning:

> number of columns of result

        not a multiple of vector length (arg 2) in: rbind(example, c(begin, end, predictions[c(begin:end)], ...

I believe this happen once the number of elements by line are different. The example data.frame repeats the same values for shorter lines until the line is full, i.e., it tries to create lines with the same number of columns.

The question is: How can I create a data.frame with different number of columns?

Any help is very much appreciated

Thanks in advance

Joao Moreira

        [[alternative HTML version deleted]]



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jun 21 21:13:58 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:32:55 EST