[R] Calculating mean, median, minimum, and maximum

John Kane jrkrideau at inbox.com
Fri Dec 19 17:48:44 CET 2014


Hi,
It looks like you are replying to some phantom. Is your correspondent actully on R-help?

John Kane
Kingston ON Canada


> -----Original Message-----
> From: mtrang at buffalo.edu
> Sent: Fri, 19 Dec 2014 08:08:29 -0800 (PST)
> To: r-help at r-project.org
> Subject: Re: [R] Calculating mean, median, minimum, and maximum
> 
> You can use the apply function which "applies" a function of your choice,
> and
> MARGIN = 2 means you want to do it columnwise:
> 
>> apply(X = df, MARGIN=2, FUN = mean, na.rm = TRUE)
>  Latitude Longitude   January  February     March     April       May
> June
>   26.9380 -109.8125  159.8454  156.4489  153.6911  150.1719  148.0885
> 149.2365
>> apply(X = df, MARGIN=2, FUN = min, na.rm = TRUE)
>  Latitude Longitude   January  February     March     April       May
> June
>    26.938  -110.688   121.204   118.713   117.293   114.398   112.357
> 113.910
>> apply(X = df, MARGIN=2, FUN = max, na.rm = TRUE)
>  Latitude Longitude   January  February     March     April       May
> June
>    26.938  -108.938   252.890   248.991   244.870   241.194   239.615
> 239.888
>> apply(X = df, MARGIN=2, FUN = median, na.rm = TRUE)
>  Latitude Longitude   January  February     March     April       May
> June
>   26.9380 -109.8120  134.5990  130.7960  127.4495  123.2100  120.8375
> 122.3835
> 
> 
> 
> --
> View this message in context:
> http://r.789695.n4.nabble.com/Calculating-mean-median-minimum-and-maximum-tp4700862p4700946.html
> Sent from the R help mailing list archive at Nabble.com.
> 
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> 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.

____________________________________________________________
FREE ONLINE PHOTOSHARING - Share your photos online with your friends and family!
Visit http://www.inbox.com/photosharing to find out more!



More information about the R-help mailing list