On Jan 29, 2010, at 6:16 PM, Cat Morning wrote:

Hi all,
I want to write a function to create multiple lists (over 100 lists). For example:

for(i in 1:5)
pi = c(1:5)

Try:
p <-list()
for(i in 1:5)
p[[i]] = 1:5

You can reference the third  elements of the first vector as:

p[[1]][3]


but when i type:
p2
i get the error
Error: object 'p2' not found

I want the lists to be numbered in this fashion, because I want to create another function that goes something like:
for(i in 1:5)
{if(pi[1]*pi[1] = = 2)
print(pi)}

any ideas on how to get around this problem would be greatly appreciated.

Thanks,
--

David Winsemius, MD
Heritage Laboratories
West Hartford, CT

______________________________________________
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