Re: [R] complex table

From: Jacques VESLOT <jacques.veslot_at_cirad.fr>
Date: Fri 09 Dec 2005 - 16:48:49 EST

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@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
>



R-help@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 Received on Fri Dec 09 16:57:57 2005

This archive was generated by hypermail 2.1.8 : Fri 09 Dec 2005 - 20:30:52 EST