[R] Creating a list of empty lists

Magnus Torfason zulutime.net at gmail.com
Wed Oct 14 17:41:18 CEST 2009


On 10/13/2009 10:06 AM, Henrique Dallazuanna wrote:
> Try this:
> 
> replicate(3, list())

Thanks!

I now have three ways to achieve my goal:

1: rep(list(list()), 3)

2: replicate(3, list())

3: Due to the way R recycles arguments, I found that it is enough to 
have construct a list(list()), and then perform an assignment using an 
argument of the length I want (using mapply()). The empty list is then 
recycled enough times to hold the corresponding values.

Best,
Magnus




More information about the R-help mailing list