[R] complex table

Jacques VESLOT jacques.veslot at cirad.fr
Fri Dec 9 06:48:49 CET 2005


it is not perfectly clear for me, but you could try :

DF[,1:72] <- as.data.frame(lapply(DF[,1:72], factor, levels=1:6))

lapply(split(DF, DF$cluster), function(x) apply(x[,-73], 2, table))
lapply(split(DF, DF$cluster), function(x) { x11() ; 
barplot(apply(x[,-73], 2, table)) })
lapply(split(DF, DF$cluster), function(x) { x11() ; 
barplot(apply(x[,-73], 2, table), beside=T) })



Michael Anyadike-Danes a écrit :

>I have a data table with 712 cases (rows) describing young people’s activities for 72 months each case has been classified into one 
>of  5 clusters.
>
>The first 72 columns are monthly activities coded 1 to 6 (e.g. school =1) and the 73rd column is the cluster number of the case.
>
>I wish to summarise the distribution of monthly activities by cluster e.g for cluster 1: 6 months school; 24 further education; etc.
>
>After looking through available resources my solution is quite complex involving – amongst other things a series of loops.
>
>I’m sure there is a quicker and simpler way (manipulating table or xtabs) but I just can’t see how to do it.
>
>Any advice?
>
>Michael Anyadike-Danes  
>
>	[[alternative HTML version deleted]]
>
>  
>
>------------------------------------------------------------------------
>
>______________________________________________
>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
>




More information about the R-help mailing list