[R] Odp: merge

Petr PIKAL petr.pikal at precheza.cz
Thu Jun 21 10:37:39 CEST 2007


r-help-bounces at stat.math.ethz.ch napsal dne 20.06.2007 18:02:07:

> 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.
> Do you know how. I know that the question isn't so easy but it's for a 
good display.
> thanks.

I may be mistaken but in such a case do you really want to do merge? Or 
just connecting both objects (data.frames) to list will do what you want?

In case you want:

pred
        Rep1...
Var1

obs
        Rep1...
Var1

in one object I think list is what I will go for.

In case you want:

state   var  Rep1 Rep2....
pred    Var1
obs     Var1
pred    Var2
obs     Var2

I would try to fiddle with merge after adding a column state to each 
object (I hesitate to call it data frame due to "supernames")

Regards
Petr


> 
> 
> 
_____________________________________________________________________________ 

> Ne gardez plus qu'une seule adresse mail ! Copiez vos mails vers Yahoo! 
Mail 
>    [[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at stat.math.ethz.ch 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.



More information about the R-help mailing list