(hec.data))
your.dfr - data.frame(eye=rep(dfr$eye,dfr$Freq),hair=rep(dfr$hair,dfr$Freq))
-Original Message-
From: Muhammad Subianto [mailto:[EMAIL PROTECTED]
Sent: Tuesday, May 10, 2005 8:38 AM
To: r-help@stat.math.ethz.ch
Subject: [R] Change the result data
Dear R-helper,
I have a data like
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))
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)))
hec.data
hair
eye Black Brown Red Blond
Green
3 4 5 6 7 8 9 10 11 12 13 14 15
as.vector(t(a))
[1] 1 4 7 10 13 2 5 8 11 14 3 6 9 12 15
hope this helps,
vito
- Original Message -
From: Muhammad Subianto [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Friday, February 27, 2004 12:28 PM
Subject: [R] Change the result
PROTECTED]
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
Using stack() would be a possibility:
a - stack(as.data.frame(hec.data))
a$eye=rownames(hec.data)
a
values ind eye
1 5 Black Green
2 15 Black Hazel
3 20 Black Blue
4 68 Black Brown
5 29 Brown Green
6 54 Brown Hazel
7 84 Brown Blue
8 119 Brown
Dear R-helper,
I use like this below (from Prof. Peter Dalgaard) and thanks to other
R-helper for your help.
Best regard,
Muhammad Subianto
as.data.frame(as.table(hec.data))
eye hair Freq
1 Green Black5
2 Hazel Black 15
3 Blue Black 20