[R] combining vectors to matrices or data frames
Erich Neuwirth
erich.neuwirth at univie.ac.at
Wed May 15 18:52:26 CEST 2002
a brute force solution would be
tmp<-c()
for(i in 1:5]){
#some calculations for a,b,c,d,e
a<- ... b<- ... c<- .. ....
tmp<-c(tmp,c(a,b,c,d,e))}
m<-t(matrix(tmp,5,5))
Jan Malte Wiener wrote:
> hi,
>
> during a for(i in 1:xx]) loop I always newly calculate a vector
> (e.g. tmp<-c(a,b,c,d,e) )
> now i need that vector to be attached at the bootom of a matrix (or
> data.frame).
>
>
> e.g.
>
> m<-matrix()
>
> for(i in 1:5]){
> #some calculations for a,b,c,d,e
> a<- ... b<- ... c<- .. ....
>
> tmp<-c(a,b,c,d,e)
>
> ??? now I need to attach this tmp to the matrix m ???
> }
>
> i couldn't get rbind or append to work properly
>
> thanks for advice,
> jan
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>
>
>
--
--
Erich Neuwirth, Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-38624 Fax: +43-1-4277-9386
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list