[R] Combine data frames using column names as "key"

Henrique Dallazuanna wwwhsd at gmail.com
Mon Sep 22 17:40:45 CEST 2008


Try:

data.frame(merge(df1, df2, by = "row.names"), row.names = 1)

On Mon, Sep 22, 2008 at 12:34 PM, jimineep <jamesrperkins at hotmail.com> wrote:
>
> Hi guys,
>
> Suppose I have 2 data frames ie:
>         values
> one    0.32
> two    0.25
> three  0.11
>
> and
>         values
> two    0.66
> one    0.74
> three  0.19
>
> nb the first column is the row names in both cases
>
> How can I combine them on the row names column? Ie to make something like
>
>
>         values.1 values.2
> one    0.32       0.74
> two    0.25       0.66
> three  0.11       0.19
>
> I guess its data.frame or c.bind but I keep getting errors when I try to
> combine them on row names...
>
> Many many thanks,
>
> Jim
> --
> View this message in context: http://www.nabble.com/Combine-data-frames-using-column-names-as-%22key%22-tp19609173p19609173.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.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O



More information about the R-help mailing list