Hi Chip,
Try this:
# For Q1
R> C1 = rbind(A,B)
or
R> C2 = do.call(rbind,list(A,B))
R> all.equal(C1,C2) # TRUE
# For Q2
R> set.seed(123)
R> vx=1:10
R> A = matrix(rnorm(500),ncol=10)
R> A2=t(sapply(A,rep,10))
R> A2[vx,]<- A[vx,]
R> A2
R> dim(A2) # 500 10
R> dim(A) # 50 10
HTH,
Jorge
On Fri, May 9, 2008 at 2:28 PM, Chip Barnaby <cbarnaby@wrightsoft.com>
wrote:
> 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@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
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
[[alternative HTML version deleted]]