Java Mailing List Archive

http://www.r-help.com/

Home » R Help for Statistical Computing »

Re: [R] construct a list that consists of lists

Zhongyi Yuan

2010-03-12

Replies: Find Java Web Hosting

Author LoginPost Reply
Hi Jim,

Dennis Murphy solved my problem by the following code.
Thank you for you suggestion. Will check out listBuilder function too.

best,
Zhongyi

# (2) A little more general: prespecify the number of list components
#    and run a one-line loop to populate the list
> l <- vector('list', 6)
> for(i in seq_along(l)) l[[i]] <- v
> l
[[1]]
[[1]]$para1
[1] 1 2 3 4 5

[[1]]$para2
[1] 5 6 7 8 9


[[2]]
[[2]]$para1
[1] 1 2 3 4 5

[[2]]$para2
[1] 5 6 7 8 9


[[3]]
[[3]]$para1
[1] 1 2 3 4 5

[[3]]$para2
[1] 5 6 7 8 9


[[4]]
[[4]]$para1
[1] 1 2 3 4 5

[[4]]$para2
[1] 5 6 7 8 9


[[5]]
[[5]]$para1
[1] 1 2 3 4 5

[[5]]$para2
[1] 5 6 7 8 9


[[6]]
[[6]]$para1
[1] 1 2 3 4 5

[[6]]$para2
[1] 5 6 7 8 9


On Fri, Mar 12, 2010 at 3:06 AM, Jim Lemon <jim@(protected):

> On 03/12/2010 05:13 PM, Zhongyi Yuan wrote:
>
>> Dear R users:
>>
>> I am hoping that someone can help with constructing a list that consists
>> of
>> list with the number of lists variable.
>> i.e. to find a convenient express(or loop sentences) to realize the
>> following:
>> list( list(para1=p1, para2=p2), list(para1=p1, para2=p2), ....,
>> list(para1=p1,para2=p2) )
>>
>> Hi Zhongyi,
> Have a look at the listBuilder function in the crank package.
>
> Jim
>
>

 [[alternative HTML version deleted]]

______________________________________________
R-help@(protected)
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
©2008 r-help.com - Jax Systems, LLC, U.S.A.