[R] how to make list() return a list of *named* elements

Hans Ekbrand hans at sociologi.cjb.net
Mon Oct 4 11:31:00 CEST 2010


On Thu, Sep 30, 2010 at 09:10:16AM -0400, Gabor Grothendieck wrote:
> A data frame is a list in which every component (i.e. every column)
> must have the same length (i.e. the same number of rows).
> data.frame() does preserve names:
> 
> > data.frame(b, my.c)
>      b my.c
> 1 22.4    8
> 2 12.2    9
> 3 10.9   15
> 4  8.5    1
> 5  9.2   14

Thanks for your suggestion. However, the reason I used list() was that
the different vectors to return usually have different lengths.

Admittedly, I should have used another example that explicated this.

-- 
Hans Ekbrand (http://sociologi.cjb.net) <hans at sociologi.cjb.net>
GnuPG key: 1024D/7050614E
Fingerprint: 1408 C8D5 1E7D 4C9C C27E 014F 7C2C 872A 7050 614E
Learn about secure email at http://www.gnupg.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20101004/86a73829/attachment.bin>


More information about the R-help mailing list