Subject: Re: [R] append data
From: Pierre Kleiber (pkleiber@honlab.nmfs.hawaii.edu)
Date: Sat 27 Jan 2001 - 06:02:02 EST
Message-ID: <3A71D7BA.5F71399D@honlab.nmfs.hawaii.edu>
Yu-Ling Wu wrote:
>
> 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?
One possibility (assuming that rawlist is a data frame) is:
rawlist <- sapply(rawlist,function(x)c(x,rep(0,4)))
-- ----------------------------------------------------------------- Pierre Kleiber Email: pkleiber@honlab.nmfs.hawaii.edu Fishery Biologist Tel: 808 983-5399/737-7544 NOAA FISHERIES - Honolulu Laboratory Fax: 808 983-2902 2570 Dole St., Honolulu, HI 96822-2396 ----------------------------------------------------------------- "God could have told Moses about galaxies and mitochondria and all. But behold... It was good enough for government work." ----------------------------------------------------------------- -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
This archive was generated by hypermail 2b25 : Thu 01 Feb 2001 - 16:14:44 EST