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

Hans Ekbrand hans at sociologi.cjb.net
Tue Oct 5 02:39:04 CEST 2010


On Mon, Oct 04, 2010 at 04:10:46PM +0200, Christophe Pallier wrote:
> See llist from Hmisc package:
> 
> library(Hmisc)
> a=rnorm(10)
> b=rnorm(5)
> llist(a,b)

Ah, that seems like what I want!

My old, ugly and redunant code looked like this

  list(utdrag=utdrag,
       n.fires.at.sites.with.one.or.more.fires=n.fires.at.sites.with.one.or.more.fires,
       more.than.one.fire.in.these.clusters=more.than.one.fire.in.these.clusters,
       n.fires.in.clusters.with.more.than.one.fire=n.fires.in.clusters.with.more.than.one.fire,
       n.fires.in.top.ten.clusters=n.fires.in.top.ten.clusters,
       m=m,
       översta.fem.procenten=översta.fem.procenten,
       these.cluster.have.alot.of.members=these.cluster.have.alot.of.members,
       n.fires.in.hotspots=n.fires.in.hotspots,
       prop.concentrated.fires=prop.concentrated.fires,
       d=d,
       real.vector=real.vector,
       the.real=the.real,
       censored.real=censored.real,
       half.of.effect.at=half.of.effect.at)

The new, nice-looking code looks like this:

  llist(utdrag,
        n.fires.at.sites.with.one.or.more.fires,
        more.than.one.fire.in.these.clusters,
        n.fires.in.clusters.with.more.than.one.fire,
        n.fires.in.top.ten.clusters,
        m,
        översta.fem.procenten,
        these.cluster.have.alot.of.members,
        n.fires.in.hotspots,
        prop.concentrated.fires,
        d,
        real.vector,
        the.real,
        censored.real,
        half.of.effect.at)

Thank you all r-helpers!
-------------- 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/20101005/e622eb9d/attachment.bin>


More information about the R-help mailing list