I get following result, while I write this code :

> lapply(1:5, function(i) c(1,2,3)^i)
[[1]]
[1] 1 2 3

[[2]]
[1] 1 4 9

[[3]]
[1]  1  8 27

[[4]]
[1]  1 16 81

[[5]]
[1]   1  32 243

This is fine. However my goal is : each element of this list should depend
on previous element like :

lis # List name
then,

lis[[i]] = lis[[i-1]] + c(1,2,3)^i

How can I modify my current code without having a "for" loop ?

Regards,
-- 
View this message in context: 
http://www.nabble.com/Question-on-creating-list-object-tp20536658p20536658.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.

Reply via email to