Hi. In a data set I have a variable that takes values from 1 to 14. For each subgroup of values of this variable, I would like to obtain some descriptive statistics of other variables present in the data set. I've been trying with a "for" loop but I couldn't get nothing. Could you please suggest me some lines? -- View this message in context: http://r.789695.n4.nabble.com/descriptive-statistics-tp3085197p3085197.html Sent from the R help mailing list archive at Nabble.com.
?aggregate ?doBy::summaryBy Le 12/13/2010 11:04, effeesse a ?crit :> Hi. In a data set I have a variable that takes values from 1 to 14. For each > subgroup of values of this variable, I would like to obtain some descriptive > statistics of other variables present in the data set. I've been trying with > a "for" loop but I couldn't get nothing. Could you please suggest me some > lines?-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. S?ugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de ********** http://www.for771.uni-bonn.de http://webapp5.rrz.uni-hamburg.de/mammals/eng/1525_8_1.php
On 12/13/2010 09:04 PM, effeesse wrote:> > Hi. In a data set I have a variable that takes values from 1 to 14. For each > subgroup of values of this variable, I would like to obtain some descriptive > statistics of other variables present in the data set. I've been trying with > a "for" loop but I couldn't get nothing. Could you please suggest me some > lines?Hi effeesse, Sure: testmat<-data.frame(sample(1:14,50,TRUE),rnorm(50),runif(50)) by(testmat[,-1],testmat[,1],mean) Jim
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20101213/d2e426e4/attachment.pl>
I am sorry, but I cannot understand how to use the "summary" function. Maybe, if I describe my needs, you could sketch a line that could work. In the data set variable "V" can take values 1 to 14. For the subgroup of individuals where "V" takes value =1 I want the mean and variance of a certain set of other variables (V1, V2, V3, V4, V5). And this for all the other subgroups for values 2 to 14. What do you suggest? -- View this message in context: http://r.789695.n4.nabble.com/descriptive-statistics-tp3085197p3085462.html Sent from the R help mailing list archive at Nabble.com.
I would suggest what we already suggested to you: ?aggregate ?by ?doBy::summaryBy We could help you more precisely if you could provide a reproducible example, as explained in the posting guide (see link at the end of every email from this list) Ivan Le 12/13/2010 15:14, effeesse a ?crit :> I am sorry, but I cannot understand how to use the "summary" function. Maybe, > if I describe my needs, you could sketch a line that could work. > In the data set variable "V" can take values 1 to 14. For the subgroup of > individuals where "V" takes value =1 I want the mean and variance of a > certain set of other variables (V1, V2, V3, V4, V5). And this for all the > other subgroups for values 2 to 14. > What do you suggest?-- Ivan CALANDRA PhD Student University of Hamburg Biozentrum Grindel und Zoologisches Museum Abt. S?ugetiere Martin-Luther-King-Platz 3 D-20146 Hamburg, GERMANY +49(0)40 42838 6231 ivan.calandra at uni-hamburg.de
Un texte encapsul? et encod? dans un jeu de caract?res inconnu a ?t? nettoy?... Nom : non disponible URL : <https://stat.ethz.ch/pipermail/r-help/attachments/20101213/2624234e/attachment.pl>
what am I supposed to put into function(x)? The indicator for extracting the subgroups? data is the df. cluster={1,...,14}. This is how I was compiling: "for (i in 1:14) { my.summary<-data$cluster==i c(mean(?),var(?)) summary(var_A~cluster, fun=my.summary,data=data) summary(var_B~cluster, fun=my.summary,data=data) summary(var_C~cluster, fun=my.summary,data=data) summary(var_D~cluster, fun=my.summary,data=data) summary(var_E~cluster, fun=my.summary,data=data) summary(var_F~cluster, fun=my.summary,data=data) summary(var_G~cluster, fun=my.summary,data=data) }" thanks for your patience. -- View this message in context: http://r.789695.n4.nabble.com/descriptive-statistics-tp3085197p3085651.html Sent from the R help mailing list archive at Nabble.com.