hec.data <-array(c(5,15,20,68,29,54,84,119,14,14,17,26,16,10,94,7),
dim=c(4,4),
dimnames=list(eye=c("Green","Hazel",
"Blue", "Brown"),
hair=c("Black", "Brown", "Red",
"Blond")))
#------------------------------------------------------
dfr <- as.data.frame(as.table(hec.data))
your.dfr <- data.frame(eye=rep(dfr$eye,dfr$Freq),hair=rep(dfr$hair,dfr$Freq))
-----Original Message-----
From: Muhammad Subianto [mailto:subianto at gmail.com]
Sent: Tuesday, May 10, 2005 8:38 AM
To: r-help at stat.math.ethz.ch
Subject: [R] Change the result data
Dear R-helper,
I have a data like:
hec.data <-array(c(5,15,20,68,29,54,84,119,14,14,17,26,16,10,94,7),
dim=c(4,4),
dimnames=list(eye=c("Green","Hazel",
"Blue", "Brown"),
hair=c("Black", "Brown", "Red",
"Blond")))
as.data.frame(as.table(hec.data))
> as.data.frame(as.table(hec.data))
eye hair Freq
1 Green Black 5
2 Hazel Black 15
3 Blue Black 20
4 Brown Black 68
5 Green Brown 29
6 Hazel Brown 54
7 Blue Brown 84
8 Brown Brown 119
9 Green Red 14
10 Hazel Red 14
11 Blue Red 17
12 Brown Red 26
13 Green Blond 16
14 Hazel Blond 10
15 Blue Blond 94
16 Brown Blond 7
>
I want to extract like,
Green Black
Green Black
Green Black
Green Black
Green Black
Hazel Black
Hazel Black
Hazel Black
Hazel Black
.
.
.
Brown Blond
Brown Blond
Brown Blond
Brown Blond
Brown Blond
Brown Blond
Brown Blond
How can I do it.
Thanks you for your help.
Best regards,
Muhammad Subianto
http://article.gmane.org/gmane.comp.lang.r.general/14604,14610
______________________________________________
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