On Sat, 10 Oct 2009, Dieter Menne wrote:
Ashta wrote:
I have a data set
x1 x2 x3
1 2 1
1 2 3
2 1 2
1 2 1
3 1 1
I want to tabulate in the following way.
1 2 3
x1 3 2 1
x2 2 3 0
x3 3 1 1
It is just like frequency distribution
See function table.
and colnames() and col()
If your data are in a matrix or data.frame called 'dat'
table(colnames(dat)[col(dat)], unlist(dat))
1 2 3
x1 3 1 1
x2 2 3 0
x3 3 1 1
HTH,
Chuck
Dieter
--
View this message in context:
http://www.nabble.com/Tabulation-tp25834839p25835126.html
Sent from the R help mailing list archive at Nabble.com.
______________________________________________
R-help@r-project.org 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.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cbe...@tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
______________________________________________
R-help@r-project.org 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.