[R] Latitudinal mean of values in a data frame

David Winsemius dwinsemius at comcast.net
Tue Dec 11 18:26:26 CET 2012


On Dec 11, 2012, at 3:17 AM, Swagath Navin wrote:

> Dear all,
>
> I have a big file containing latitude points(-10 to 80) and  
> corresponding values.
> Example data
>
> Lat=c(69.48134, 69.49439, 69.50736, 69.52026, 69.52438, 69.53308,  
> 69.53746, 69.54365, 69.54582, 69.6884, 69.69272, 69.998, 70.00055,  
> 70.00106, 70.00295, 70.00308, 70.00363, 70.00427, 70.00665,  
> 70.00906, 70.01049, 70.01053, 70.01075, 70.01208, 70.01236,  
> 70.01418, 70.01452, 70.01646, 70.01983, 70.0209, 70.02298, 70.02386,  
> 70.02533, 70.02534, 70.02856, 70.0291, 70.02983, 70.03091, 70.03267,  
> 70.03423)
>
> Value=c(0.18917075, 0.18856758, 0.1877328, 0.18664664, 0.18871901,  
> 0.18528864, 0.18797649, 0.18999862, 0.1836383, 0.15414046,  
> 0.18542965, 0.13914858, 0.1654665, 0.12885736, 0.18935319,  
> 0.1912378, 0.14910094, 0.17590007, 0.18369354, 0.12546185,  
> 0.16096813, 0.18851039, 0.14388486, 0.19098477, 0.17252013,  
> 0.12965086, 0.12256515, 0.18159349, 0.15608113, 0.18742996,  
> 0.13858418, 0.16865459, 0.19058037, 0.12531143, 0.19189732,  
> 0.12019097, 0.1790819, 0.15086053, 0.18607724,  0.13330366)
>
> dframe=data.frame(Lat, Value)
>
> i would like to find latitudinal mean such that my output looks like  
> the below:
>
> Lat Value
> 69 0.18
> 70 0.16

?trunc   # some people prefer floor()
?tapply

-- 

David Winsemius, MD
Alameda, CA, USA




More information about the R-help mailing list