Skip to content
Prev 339483 / 398500 Next

average and median values for each of the class

On Apr 26, 2014, at 5:37 PM, Nico Met wrote:

            
Well it does have a dimension attribute but it is a data.frame, NOT a matrix. The term "class" is a reserved word in R. What is it that you mean by that word? if it is for each column then:

sapply( dat, function(x) c( mean(x), median(x)) )
class    name1    name2     name3    name4    name5     name6
mean_x   2.4375 2.350258 1.102291 0.5358036 2.343448 1.895963 0.6242466
median_x 2.0000 2.436813 1.094910 0.5478146 2.421528 1.942289 0.6497279
           name7     name8    name9    name10    name11
mean_x   1.67054 0.2742449 2.094122 0.6388536 0.3736069
median_x 1.72933 0.2770331 2.106486 0.6322816 0.3623650