From eriki at ccbr.umn.edu  Wed Oct 13 21:35:11 2010
From: eriki at ccbr.umn.edu (Erik Iverson)
Date: Wed, 13 Oct 2010 14:35:11 -0500
Subject: [Rd] list comprehension to create an arbitrary-sized list with
 arbitrary names/values
In-Reply-To: <AANLkTik7xjr5TaH1AcFtg5cUJkTg2cfEPGy8i-RT69GY@mail.gmail.com>
References: <AANLkTik7xjr5TaH1AcFtg5cUJkTg2cfEPGy8i-RT69GY@mail.gmail.com>
Message-ID: <4CB609EF.4020107@ccbr.umn.edu>

This question probably belongs on R-help instead of R-devel.

What works best for you will depend on how big 'mylist' is.

An article discussing some possibilities can be found at:
http://opendatagroup.com/2009/07/26/hash-package-for-r/

Hope this helps,
--Erik

Steve Kim wrote:
> In python, one can do this
> 
> mydict = dict([(keyfun(x), valfun(x)) for x in mylist])
> 
> to create a dictionary with whatever keys and values we want from an
> input list of arbitrary size. In R, I want to similarly create a list
> with names/values that are generated by some keyfun and valfun
> (assuming that keyfun is guaranteed to return something suitable as a
> name). How can I do this?
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel



[Rd] list comprehension to create an arbitrary-sized list with arbitrary names/values
Erik Iverson