[R] Create vectors from a vector
Dimitris Kapetanakis
gamitor at gmail.com
Sun Mar 14 13:11:18 CET 2010
Dear all,
I would like to create a number of vectors which contain the the first n
elements of an existing vector.
For example I have the vectors vnk (200x1) and vro(200x1) and I want to
create 200 vectors that contain the 1st till the n_th element of the vectors
and thus be able to create a vector s with 200 elements which are the
product of all these vectors:
i.e s1<-vnk[1]%*%vro[1] +p^(length(vp[1]+1))
s2<-vnk[1:2]%*%vro[1:2]+p^(length(vp[1:2]+1))
s3<-vnk[1:3]%*%vro[1:3]+p^(length(vp[1:3]+1))
...............................
...............................
s200<-vnk[1:200]%*%vro[1:200]+p^(length(vp[1:200]+1))
s<-[s1 s2 ......s200]
In the code I created I can calculate only the 200th element
vnk<-t(nk^(200:0))
vro<-ro^(0:200)
s<-nz*e*(vnk%*%vp)+p^(length(vp))
if lapply wouldn't need functions but vector arguments it would do the job
perfectly but I don't know the respective command for vectors. If you know
please tell me.
Any help would be highly appreciated
Thanks a lot
Dimitris
--
View this message in context: http://n4.nabble.com/Create-vectors-from-a-vector-tp1592334p1592334.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list