An embedded and charset-unspecified text was scrubbed... Name: not available Url: https://stat.ethz.ch/pipermail/r-help/attachments/20070620/ea57803a/attachment.pl
merge
3 messages · elyakhlifi mustapha, PIKAL Petr, Mike Meredith
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!
[[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.
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.