[R] Change the result data
John Fox
jfox at mcmaster.ca
Fri Feb 27 13:27:05 CET 2004
Dear Muhammad,
One approach is:
class(hec.data) <- "table"
as.data.frame(hec.data)
I hope that this helps,
John
> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of
> Muhammad Subianto
> Sent: Friday, February 27, 2004 6:28 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")))
> > hec.data
> hair
> eye Black Brown Red Blond
> Green 5 29 14 16
> Hazel 15 54 14 10
> Blue 20 84 17 94
> Brown 68 119 26 7
> >
>
> but I want the result like below.:
>
> hair eye counts
> Black Green 5
> Black Hazel 15
> Black Blue 20
> Black Brown 68
> Brown Green 29
> Brown Hazel 54
> Brown Blue 84
> Brown Brown 119
> Red Green 14
> Red Hazel 14
> Red Blue 17
> Red Brown 26
> Blond Green 16
> Blond Hazel 10
> Blond Blue 94
> Blond Brown 7
>
> How can I do it. Thanks you for your help.
>
> Best regards,
> Muhammad Subianto
More information about the R-help
mailing list