[R] related to my previous sapply question]

markleeds at verizon.net markleeds at verizon.net
Tue Jun 27 03:46:43 CEST 2006


in my previous post in which i asked about creating sequences
from two vectors of numbers,  all suggestions worked.

tradevectors<-mapply(seq,from=tempa,to=tempb)

or 

tradevectors<-sapply(1:length(tempa),function(x) seq(tempa[x],tempb[x])

>both return a list with 3 components.

the problem is that i want to take these 3 sequences and

use them as the indices of two other vectors, X and Y and mutiply them  ( element by element )


>so, i tried 
>
>temp<-sapply(1:length(tradevectors),function(i)X[tradevectors[[i]]]*Y[tradevectors[[i]]]


basically, the sequence output from the previous command are
indices to two vectors that i want to multiply ( element
by element ).

but, the message i get is that i cannot coerce list object to double. 

i looked up the info on unlist, but that just
makes long vector. i need 3 vectors.

                                   thanks



More information about the R-help mailing list