Re: [R] append data

About this list Date view Thread view Subject view Author view Other groups

Subject: Re: [R] append data
From: Peter Dalgaard BSA (p.dalgaard@biostat.ku.dk)
Date: Sat 27 Jan 2001 - 05:39:35 EST


Message-ID: <x2bssuf6h4.fsf@blueberry.kubism.ku.dk>

Yu-Ling Wu <yuling5@yahoo.com> writes:

> Hi,
>
> I read a dataset into R. It looks like this:
>
> > rawlist
> x1 x2 x3
> 2 12 64
> 5 12 42
> 5 9 42
> 18 14 535
> 26 23 751
>
> Now I want to append some values of zero to let it
> look like this:
>
> x1 x2 x3
> 2 12 64
> 5 12 42
> 5 9 42
> 18 14 535
> 26 23 751
> 0 0 0
> 0 0 0
> 0 0 0
> 0 0 0
>
> How to do this?

Something along the lines of

zeros <- as.data.frame(matrix(0,4,3))
names(zeros) <- names(rawlist)
rbind(rawlist, zeros)

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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@stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


About this list Date view Thread view Subject view Author view Other groups

This archive was generated by hypermail 2b25 : Thu 01 Feb 2001 - 16:14:44 EST