Is this what you want:

> aggregate(x$Sim_1986, list(trunc(x$Latitude)), mean)
  Group.1        x
1      82 55.04276
2      83 60.26186
3      84 39.40297
4      85 22.12000
>


On Thu, Apr 30, 2009 at 11:50 AM, Steve Murray <smurray...@hotmail.com>wrote:

>
> Dear all,
>
> I have a data frame of three columns, which I have sorted by Latitude as
> follows:
>
> > test2[60:80,]
>      Latitude Longitude  Sim_1986
> 61948    85.25    -29.25  2.175345
> 61957    85.25    -28.75  8.750486
> 61967    85.25    -28.25 33.569305
> 61977    85.25    -27.75 23.702572
> 61988    85.25    -27.25 26.488602
> 62000    85.25    -26.75 23.915724
> 62012    85.25    -26.25 25.055082
> 62027    85.25    -25.75 26.609823
> 62047    85.25    -25.25 28.813068
> 62066    84.25    -24.75 25.069952
> 52341    84.75    -82.25 34.940380
> 52434    84.75    -81.75 56.192116
> 52531    84.75    -81.25 41.409431
> 52616    83.75    -80.75 56.717590
> 52701    83.75    -80.25 68.887123
> 52781    83.75    -79.75 74.133286
> 52865    83.75    -79.25 41.309422
> 52951    82.25    -78.75 69.863419
> 53052    82.25    -78.25 21.480116
> 53164    82.25    -77.75 58.799141
> 55979    82.25    -68.75 70.028358
>
>
> What I am hoping to do is to use the aggregate command to calculate the
> mean of Sim_1986' per 1-degree increment of Latitude. So, using the above
> subset of the data frame as an example, a mean would be produced based on
> the Sim_1986 values between where Latitude 85, 84, 83, 82. The maximum
> latitude in the dataset as a whole is 83.75 and the minimum is -55.75.
>
> Is it possible to also output corresponding latitude values for each
> 'grouped mean', so that I can easily associate each mean value with its
> latitudinal band?
>
>
> Many thanks for any help offered,
>
> Steve
>
>
> _________________________________________________________________
> [[elided Hotmail spam]]
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html<http://www.r-project.org/posting-guide.html>
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Jim Holtman
Cincinnati, OH
+1 513 646 9390

What is the problem that you are trying to solve?

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
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.

Reply via email to