[R] function to create multiple lists

2010-01-29 Thread Cat Morning
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) 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

[R] Make the output (from a Loop function) a Vector

2009-12-27 Thread Cat Morning
Hi all, I have made a loop function which prints outputs. For example:  for (i in 1:5) + print(i) [1] 1 [1] 2 [1] 3 [1] 4 [1] 5 However, I would like the output to given as a list or a vector, e..g c(1,2,3,4,5). Is it possible to do this? (The function I am using outputs many 1000s of results

[R] input a list into a function

2009-12-25 Thread Cat Morning
  I want to input a list into a function. But i get the error "Error in +{ : invalid argument to unary operator". How do I avoid this error?   Here is an example of this problem:   > g = c(2, 4, 8, 16, 32, 64, 128, 122, 110, 86, 38, 76, 18, 36, 72, 10, 20, 40, > 80, 26) > for (i in 1:20)  + {f