I have a table like this: A B aaa 111 bbb 222 ccc 333 ddd 444 and I would like a new row C: A B C aaa 111 aaa.111 bbb 222 bbb.222 ccc 333 ccc.333 ddd 444 ddd.444 How can I do this ??? Thanks Alberto -- View this message in context: http://r.789695.n4.nabble.com/Concat-two-rows-tp3064998p3064998.html Sent from the R help mailing list archive at Nabble.com.
Hi, Try this, within(data.frame(A=letters[1:5], B=1:5), C <- paste(A, B, sep=".")) HTH, baptiste On Nov 30, 2010, at 9:30 AM, alcesgabbo wrote:> > I have a table like this: > > > A B > aaa 111 > bbb 222 > ccc 333 > ddd 444 > > and I would like a new row C: > > A B C > aaa 111 aaa.111 > bbb 222 bbb.222 > ccc 333 ccc.333 > ddd 444 ddd.444 > > > How can I do this > ??? > > Thanks > Alberto > > -- > View this message in context: http://r.789695.n4.nabble.com/Concat-two-rows-tp3064998p3064998.html > Sent from the R help mailing list archive at Nabble.com. > > ______________________________________________ > R-help at 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.
have a look at function paste(), e.g.,
Dat <- data.frame(A = c("aaa", "bbb", "ccc",
"ddd"),
B = c(111, 222, 333, 444))
Dat$C <- paste(Dat$A, Dat$B, sep = ".")
Dat
I hope it helps.
Best,
Dimitris
On 11/30/2010 9:30 AM, alcesgabbo wrote:>
> I have a table like this:
>
>
> A B
> aaa 111
> bbb 222
> ccc 333
> ddd 444
>
> and I would like a new row C:
>
> A B C
> aaa 111 aaa.111
> bbb 222 bbb.222
> ccc 333 ccc.333
> ddd 444 ddd.444
>
>
> How can I do this
> ???
>
> Thanks
> Alberto
>
--
Dimitris Rizopoulos
Assistant Professor
Department of Biostatistics
Erasmus University Medical Center
Address: PO Box 2040, 3000 CA Rotterdam, the Netherlands
Tel: +31/(0)10/7043478
Fax: +31/(0)10/7043014
Web: http://www.erasmusmc.nl/biostatistiek/