[R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Chien-Pang Chin
Hi all: I have a problem when I want to do operation a sequence or matrix created by loop and list() or data.frame(). Here is the example. > for(i in 1:n) (k[i]=list(c(0:max[i]))) > k[1]+1 Error in k[1] + 1 : non-numeric argument to binary operator What should I do to correct this pro

Re: [R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Phil Spector
Chien-Pang - Here's a *reproducible* example that should answer your question: k = list() n = 10 max = 10:19 for(i in 1:n) (k[i]=list(c(0:max[i]))) k[[1]] + 1 [1] 1 2 3 4 5 6 7 8 9 10 11 - Phil Spector

[R] loop, list() and non-numeric argument to binary operator

2010-09-15 Thread Chien-Pang Chin
Hi all: I have a problem when I want to do operation a sequence or matrix created by loop and list() or data.frame(). Here is the example. > for(i in 1:n) (k[i]=list(c(0:max[i]))) > k[1]+1 Error in k[1] + 1 : non-numeric argument to binary operator What should I do to correct this pro