[R] Summary statistics for matrix columns

David Winsemius dwinsemius at comcast.net
Sun Nov 25 01:14:24 CET 2012


On Nov 24, 2012, at 4:58 AM, frespider wrote:

>
>
> HI A.k,
>
> I need one more question, if you can answer it please
>
> M <- matrix(sample(1:8000),nrow=100)
> colnames(M)<- paste("Col",1:ncol(M),sep="")
> apply(M,2,function(x) c(Min=min(x),"1st Qu" =quantile(x,  
> 0.25,names=FALSE),
>                        Range = range(x),
>                        Median = quantile(x, 0.5, names=FALSE),
>                        Mean= mean(x),Std=sd(x),
>                        "3rd Qu" = quantile(x,0.75,names=FALSE),
>                        IQR=IQR(x),Max = max(x)))
>
> why I get two range . isn't range mean the different between the max  
> and min

If you want the "span" (what you are calling the range) of the range  
(min and max) you can do this:

myRange = diff(range(x))

-- 
David
>
>
>

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list