[R] trivial question about nested loops

Gabor Grothendieck ggrothendieck at myway.com
Thu Sep 2 19:18:20 CEST 2004


dan roberts <bro092 <at> yahoo.com> writes:

: I tried your solutions and they almost work. The problem seems
: to be d$Y[k]. When I run the code with d$Y[k], I get an empty
: matrix (all 0s). However, if I replace d$Y[k] with, for example,
: d&Y4, then I get a matrix with one of the results I am looking
: for. Do you have any idea how I could make d$Y[k] actually pull
: the columns from the imported table (d$Y1, d$Y2, ...)?
: I tried
: sum(paste("d$Y",k,sep="")*exp(-1i*j*d$X)) 
: but I got 
: Error in paste("d$Y", k, sep = "") * exp(-(0+1i) * j * d$X) : 
:         non-numeric argument to binary operator

You need to post your data.  Without that no one can try out their
solution prior to posting.

If d is your data frame include the output of

    dput(d)

in your post.   If there are a large number of rows then just
provide the first few:

    dput(d[1:10,])




More information about the R-help mailing list