Hi Every one, I have a dataframe "class" with "name", "sex", "age", "height", "Weight". if i caluclate summary statistics with the below code numSummary(class[,c("Height", "Weight")], groups=class$Name, statistics=c("mean", "sd", "quantiles"), quantiles=c(0, .25,.5,.75,1)) iam getting output like this Variable: Height mean sd 0% 25% 50% 75% 100% n Alfred 69.0 NA 69.0 69.0 69.0 69.0 69.0 1 Alice 56.5 NA 56.5 56.5 56.5 56.5 56.5 1 Barbara 65.3 NA 65.3 65.3 65.3 65.3 65.3 1 Carol 62.8 NA 62.8 62.8 62.8 62.8 62.8 1 Variable: Weight mean sd 0% 25% 50% 75% 100% n Alfred 112.5 NA 112.5 112.5 112.5 112.5 112.5 1 Alice 84.0 NA 84.0 84.0 84.0 84.0 84.0 1 Barbara 98.0 NA 98.0 98.0 98.0 98.0 98.0 1 Carol 102.5 NA 102.5 102.5 102.5 102.5 102.5 1 now my question is i want output like this height weight Alfred mean sd 0% 25% 50% 75% 100% n Alice mean sd 0% 25% 50% 75% 100% n Barbara mean sd 0% 25% 50% 75% 100% n it is nothing but a numerical summaries across varibales. is it possible. Thanks in Advance. -- View this message in context: http://www.nabble.com/numerical-summaries-across-variables.-tp25234915p25234915.html Sent from the R help mailing list archive at Nabble.com.
Hi here, may be you can play with reshape, or may be aggregate and reshape... good luck milton On Tue, Sep 1, 2009 at 2:17 AM, rajclinasia <raj@clinasia.com> wrote:> > Hi Every one, > I have a dataframe "class" with "name", "sex", "age", "height", "Weight". > if i caluclate summary statistics with the below code > > numSummary(class[,c("Height", "Weight")], groups=class$Name, > statistics=c("mean", "sd", "quantiles"), quantiles=c(0, > .25,.5,.75,1)) > > iam getting output like this > > Variable: Height > mean sd 0% 25% 50% 75% 100% n > Alfred 69.0 NA 69.0 69.0 69.0 69.0 69.0 1 > Alice 56.5 NA 56.5 56.5 56.5 56.5 56.5 1 > Barbara 65.3 NA 65.3 65.3 65.3 65.3 65.3 1 > Carol 62.8 NA 62.8 62.8 62.8 62.8 62.8 1 > > Variable: Weight > mean sd 0% 25% 50% 75% 100% n > Alfred 112.5 NA 112.5 112.5 112.5 112.5 112.5 1 > Alice 84.0 NA 84.0 84.0 84.0 84.0 84.0 1 > Barbara 98.0 NA 98.0 98.0 98.0 98.0 98.0 1 > Carol 102.5 NA 102.5 102.5 102.5 102.5 102.5 1 > > now my question is i want output like this > > height weight > Alfred mean > sd > 0% > 25% > 50% > 75% > 100% > n > Alice mean > sd > 0% > 25% > 50% > 75% > 100% > n > Barbara mean > sd > 0% > 25% > 50% > 75% > 100% > n > > it is nothing but a numerical summaries across varibales. is it possible. > > Thanks in Advance. > > > -- > View this message in context: > http://www.nabble.com/numerical-summaries-across-variables.-tp25234915p25234915.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. >[[alternative HTML version deleted]]
rajclinasia wrote:> Hi Every one, > I have a dataframe "class" with "name", "sex", "age", "height", "Weight". > if i caluclate summary statistics with the below code > > numSummary(class[,c("Height", "Weight")], groups=class$Name, > statistics=c("mean", "sd", "quantiles"), quantiles=c(0, > .25,.5,.75,1)) > > iam getting output like this > > Variable: Height > mean sd 0% 25% 50% 75% 100% n > Alfred 69.0 NA 69.0 69.0 69.0 69.0 69.0 1 > Alice 56.5 NA 56.5 56.5 56.5 56.5 56.5 1 > Barbara 65.3 NA 65.3 65.3 65.3 65.3 65.3 1 > Carol 62.8 NA 62.8 62.8 62.8 62.8 62.8 1 > > Variable: Weight > mean sd 0% 25% 50% 75% 100% n > Alfred 112.5 NA 112.5 112.5 112.5 112.5 112.5 1 > Alice 84.0 NA 84.0 84.0 84.0 84.0 84.0 1 > Barbara 98.0 NA 98.0 98.0 98.0 98.0 98.0 1 > Carol 102.5 NA 102.5 102.5 102.5 102.5 102.5 1 > > now my question is i want output like this > > height weight > Alfred mean > sd > 0% > 25% > 50% > 75% > 100% > n > Alice mean > sd > 0% > 25% > 50% > 75% > 100% > n > Barbara mean > sd > 0% > 25% > 50% > 75% > 100% > n > > it is nothing but a numerical summaries across varibales. is it possible. > >Hi Raj, I think you may have to write a print function for this. Assign the result of numSummary to an object, use "str" to find out the structure and then use "cat" to display the bits in the format you want. I don't have Rcmdr on my system and haven't been able to install it as R refuses to believe that I have Tcl-Tk available. Thus I can't tell you exactly how to do this. Jim