[R] Data frame row manipulation

Chip Barnaby cbarnaby at wrightsoft.com
Fri May 9 20:28:47 CEST 2008


Greetings,

Q #1
------

How does one combine data frames by row ... no cleverness a la 
merge(), just add rows.

For example, given A with 20 rows and B with 30 rows, I want C = 
combine( A, B) having 50 rows.

Columns having matching names should be filled from both (all) 
sources with suitable coercion, unmatched would get NA in rows whose 
source does not have that column.


Q #2
------

Given data frame A having various columns including "vx".

I want to create a new data frame A2 that has 10 copies of each row 
in A, all the same as the source row except vx=seq(1:10).  The source 
row value of vx is overwritten.  A2 would have 10 times as many rows as A.

I have of course discarded idea of using of a for loop, but maybe 
that is what it takes.


TIA etc,

Chip Barnaby






---------------------------------------------------------
Chip Barnaby                   cbarnaby at wrightsoft.com
Vice President of Research
Wrightsoft Corp.               781-862-8719 x118 voice
131 Hartwell Ave               781-861-2058 fax
Lexington, MA 02421         www.wrightsoft.com



More information about the R-help mailing list