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

2010-03-12 Thread Jim Lemon

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

__
R-help@r-project.org mailing list
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.


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

2010-03-12 Thread Zhongyi Yuan
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 j...@bitwrit.com.au wrote:

 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@r-project.org mailing list
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.


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

2010-03-12 Thread Henrique Dallazuanna
You can do this also, using replicate:

replicate(6, list(para1 = 1:5, para2 = 5:9), simplify = FALSE)

On Fri, Mar 12, 2010 at 2:51 PM, Zhongyi Yuan zhongyi-y...@uiowa.edu wrote:
 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 j...@bitwrit.com.au wrote:

 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@r-project.org mailing list
 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.




-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40 S 49° 16' 22 O

__
R-help@r-project.org mailing list
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.


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

2010-03-12 Thread Zhongyi Yuan
Hi Henrique,

Great.
I tried a similar thing but used
list( replicate(6, list(para1 = 1:5, para2 = 5:9), simplify = FALSE) )

and didn't work. Seems I don't need list(...).
Thanks.

Zhongyi

On Fri, Mar 12, 2010 at 11:56 AM, Henrique Dallazuanna www...@gmail.comwrote:

 You can do this also, using replicate:

 replicate(6, list(para1 = 1:5, para2 = 5:9), simplify = FALSE)

 On Fri, Mar 12, 2010 at 2:51 PM, Zhongyi Yuan zhongyi-y...@uiowa.edu
 wrote:
  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 j...@bitwrit.com.au wrote:
 
  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@r-project.org mailing list
  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.
 



 --
 Henrique Dallazuanna
 Curitiba-Paraná-Brasil
 25° 25' 40 S 49° 16' 22 O


[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.


[R] construct a list that consists of lists

2010-03-11 Thread Zhongyi Yuan
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) )

I appreciate your help.

best,
Zhongyi

[[alternative HTML version deleted]]

__
R-help@r-project.org mailing list
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.