An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120402/e0218869/attachment.pl>
table: output: all variables in rows
3 messages · David Winsemius, Marion Wenty
On Apr 2, 2012, at 7:11 AM, Marion Wenty wrote:
Dear people,
I would like to create a table out of a data.frame.
How can I determine, which variables are put in the rows and which
in the
columns?
I would like to get all the variables in the ROWS:
I am including a simple example:
D<-data.frame(age=c(8,9,10),county=c("B","W","W"))
the output should have the following structure:
8 B 1
8 W 0
9 B 0
9 W 1
10 B 0
10 W 1
You can use the order() function with "[" to rearrange this to suit you needs: > as.data.frame(xtabs(~age+county, data=D)) age county Freq 1 8 B 1 2 9 B 0 3 10 B 0 4 8 W 0 5 9 W 1 6 10 W 1
[[alternative HTML version deleted]]
Posting in HTML is considered impolite on Rhelp.
David Winsemius, MD West Hartford, CT
2 days later
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120405/ef00e370/attachment.pl>