[R] merge

Mike Meredith mmeredith at wcs.org
Fri Jun 22 08:47:58 CEST 2007


Looking at the data, maybe what you need is an array:

array(c(A, B), c(5,6,2), dimnames=list(rownames(A),
    colnames(A), c("obs","pred")))

This allows you to keep the names and 'supernames'.

This will work if A and B are matrices, not data frames, so you may have to
use 'as.matrix' first.

HTH, Mike.


elyakhlifi mustapha wrote:
> 
> Hello,
> ok I know how to do to merge matrix or data.frame by "row.names" but my
> true objectif is to merge for example this data.frame:
> 
>> A
>       obs
>        Rép1 Rép2 Rép3 Rép4 Rép5 Rép6
>   Var1  145  145  150  145  140  145
>   Var2  150  150  160  155  155  150
>   Var3  155  155  160  150  150  140
>   Var4  150  145  145  145  140  145
>   Var5  135  130  145  135  135  130
> 
> and 
> 
>> B
>       pred
>          Rép1   Rép2   Rép3   Rép4   Rép5   Rép6
>   Var1 146.00 144.00 151.00 145.00 143.00 141.00
>   Var2 154.33 152.33 159.33 153.33 151.33 149.33
>   Var3 152.67 150.67 157.67 151.67 149.67 147.67
>   Var4 146.00 144.00 151.00 145.00 143.00 141.00
>   Var5 136.00 134.00 141.00 135.00 133.00 131.00
> 
> and the main difficulty is to keep the names and the supernames.
> 

-- 
View this message in context: http://www.nabble.com/merge-tf3953336.html#a11247082
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list