[R] MODE , VARIANCE , NTH PERCENTAILE

chamilka cmanoj4 at gmail.com
Wed Jul 11 16:43:24 CEST 2012


Din't you try sapply function?
I tried it for you. 
Just convert your matrix into a data frame using as.data.frame and then 
*> rantony*
     ABC PQR XYZ MNO
[1,]   3   6   7  15
[2,]   2  12  24  15
[3,]  20   5   1   2
[4,]  25  50  15  35

*> rantony=as.data.frame(rantony)*

*> sapply(rantony,var)* #calculates column wise variance
      ABC       PQR       XYZ       MNO 
137.66667 457.58333  99.58333 185.58333 

*> sapply(rantony,Mode)*  #calculates column vise Mode, where the mode
function is available in
http://cran.r-project.org/web/packages/prettyR/index.html  prettyR  package
      ABC       PQR       XYZ       MNO 
">1 mode" ">1 mode" ">1 mode"      "15" 
# the above means there are no modes in first three columns and in the last
column Mode is 15
> sapply(rantony,quantile) 
       ABC   PQR   XYZ   MNO
0%    2.00  5.00  1.00  2.00
25%   2.75  5.75  5.50 11.75
50%  11.50  9.00 11.00 15.00
75%  21.25 21.50 17.25 20.00
100% 25.00 50.00 24.00 35.00

--
View this message in context: http://r.789695.n4.nabble.com/MODE-VARIANCE-NTH-PERCENTAILE-tp4636112p4636142.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list