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

From: Petr Pikal <petr.pikal_at_precheza.cz>
Date: Tue 21 Jun 2005 - 22:34:38 EST


Hi

from help page

Details:

     A data frame is a list of variables of the same length with unique
						^^^^^^^^^^
     row names, given class '"data.frame"'.

So you need to use a different sructure (e.g.list) or you have to ensure that you rbind vectors of same length.

HTH
Petr

On 21 Jun 2005 at 12:09, Joćo Mendes Moreira wrote:

> 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

Petr Pikal
petr.pikal@precheza.cz



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 22:44:13 2005

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