[R] trivial question about nested loops

dan roberts bro092 at yahoo.com
Thu Sep 2 16:26:31 CEST 2004


It's a trivial question but I haven't found a solution in the
full reference manual. How can I make the code below run? Would
an array/matrix solution be faster? Please provide a short
example, if possible.

Thanks in advance,

for (k in 1:5) 
for (k in 1:5) {
	for(j in 1:5) 
		f[k][[j]] <- sum(d$Y[k]*exp(-1i*j*d$X)) }
Error: Object "f" not found

(I want f[k] to become f1,...,f5; and d$Y[k] should be

More information about the R-help mailing list