[R] rbind

Patrick Hausmann patrick.hausmann at uni-bremen.de
Fri Jun 21 11:58:47 CEST 2002


Hello,

I am sure this is a trivial question, but I don't get it...
Having a dataframe (b.70) like that:

> b.70[1:4,2:3]
         ARG        AUS
1960     19041     25949
1961     19675     25451
1962     19302     26463
1963     18121     27644

Now I want to calculate the log for each year and save the 
result in a new dataframe called 'x'.

x<- data.frame(w=NULL)
for(i in 1:3)
ja <- b.70[i:(i+1),2:3]
  af <- log(ja[2,]/ja[1,])
  x <-  rbind(x,af)

But this saves only the last value of 'af' in 'x'
> x
        ARG          AUS      
1963 -0.06313723  0.04366118

So, how can I preserve the old values of x?

Thanks a lot
Patrick

-------------
Patrick Hausmann
Friedrich-Wilhelm Str. 37 - D-28199 Bremen
Tel. +49 421 5980631 - Fax. +49 421 5980632
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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