[R] data format issue

jim holtman jholtman at gmail.com
Sun Dec 21 03:18:22 CET 2008


Does this do it for you:

> # quick and dirty -- remove the 'mm' from the data and then aggregate
> x$hours <- (x$LST %/% 100) * 100
> aggregate(x$mph, list(x$hours), mean)
    Group.1        x
1 506010000 13.82500
2 506010100 17.55000
3 506010200 23.04167
4 506010300 22.00000
>
>

You can also 'filter' out the months for only the summer

On Sat, Dec 20, 2008 at 9:09 PM, Sherri Heck <sheck at ucar.edu> wrote:
> Dear all-
>
> I have a dataset (see a sample below - but the whole dataset is June 2005 -
> June 2008).  The "LST" format is "YYMMDDHHmm" and I would like to get the
> hourly average of the "mph" for the summer months (spanning all years). I
> have been trying to use "aggregate" but am not having much success at all!
>  any thoughts would be greatly appreciated.
>
> thanks-
>
> sherri
>
>   LST   inch     mph    Deg   DegF  DegF    %    volts   Deg    mph   w/m2
> 0506010000   0.00   13.6  218.1   36.8   -999   65.1   -999   -999   18.2
>  0.2
> 0506010005   0.00   12.9  214.3   36.8   -999   65.5   -999   -999   16.9
>  0.2
> 0506010010   0.00   14.4  215.7   36.9   -999   65.4   -999   -999   20.4
>  0.2
> 0506010015   0.00   13.8  215.8   36.8   -999   65.7   -999   -999   19.7
>  0.3
> 0506010020   0.00   11.9  213.4   36.8   -999   65.6   -999   -999   14.6
>  0.2
> 0506010025   0.00   12.7  212.4   36.8   -999   65.4   -999   -999   16.9
>  0.2
> 0506010030   0.00   14.1  215.8   36.8   -999   65.9   -999   -999   19.1
>  0.2
> 0506010035   0.00   14.8  217.2   36.7   -999   66.2   -999   -999   20.4
>  0.2
> 0506010040   0.00   16.2  222.0   36.8   -999   66.6   -999   -999   20.2
>  0.2
> 0506010045   0.00   13.6  219.5   36.7   -999   66.6   -999   -999   18.4
>  0.2
> 0506010050   0.00   14.8  217.6   36.7   -999   66.2   -999   -999   20.0
>  0.2
> 0506010055   0.00   13.1  214.8   36.7   -999   65.9   -999   -999   20.2
>  0.2
> 0506010100   0.00   12.2  214.3   36.7   -999   65.2   -999   -999   15.6
>  0.2
> 0506010105   0.00   14.2  207.8   36.7   -999   65.0   -999   -999   19.9
>  0.2
> 0506010110   0.00   15.4  207.0   36.7   -999   64.4   -999   -999   20.2
>  0.2
> 0506010115   0.00   17.2  205.9   36.7   -999   64.5   -999   -999   22.1
>  0.2
> 0506010120   0.00   16.8  208.9   36.8   -999   65.0   -999   -999   21.9
>  0.2
> 0506010125   0.00   18.4  214.0   36.9   -999   65.1   -999   -999   26.4
>  0.2
> 0506010130   0.00   17.3  214.7   37.0   -999   65.5   -999   -999   24.0
>  0.2
> 0506010135   0.00   18.4  214.3   37.1   -999   65.2   -999   -999   24.9
>  0.2
> 0506010140   0.00   19.6  216.6   37.3   -999   65.3   -999   -999   26.7
>  0.2
> 0506010145   0.00   19.7  220.5   37.5   -999   65.1   -999   -999   27.5
>  0.2
> 0506010150   0.00   19.6  215.5   37.6   -999   64.6   -999   -999   26.4
>  0.2
> 0506010155   0.00   21.8  220.1   37.8   -999   64.1   -999   -999   31.2
>  0.2
> 0506010200   0.00   23.4  222.9   37.9   -999   63.8   -999   -999   31.8
>  0.2
> 0506010205   0.00   24.0  221.7   37.9   -999   63.7   -999   -999   30.3
>  0.2
> 0506010210   0.00   24.2  223.4   38.0   -999   63.5   -999   -999   28.2
>  0.2
> 0506010215   0.00   23.8  224.9   38.0   -999   63.4   -999   -999   30.3
>  0.2
> 0506010220   0.00   23.9  225.1   38.1   -999   63.5   -999   -999   29.5
>  0.2
> 0506010225   0.00   23.9  227.4   38.1   -999   63.5   -999   -999   30.3
>  0.2
> 0506010230   0.00   23.9  226.0   38.0   -999   63.6   -999   -999   27.5
>  0.2
> 0506010235   0.00   21.5  221.4   38.0   -999   63.7   -999   -999   28.4
>  0.2
> 0506010240   0.00   22.3  222.6   37.9   -999   63.8   -999   -999   27.9
>  0.2
> 0506010245   0.00   21.5  223.9   37.9   -999   64.0   -999   -999   28.4
>  0.2
> 0506010250   0.00   22.2  226.7   37.8   -999   64.2   -999   -999   27.7
>  0.2
> 0506010255   0.00   21.9  223.5   37.8   -999   64.3   -999   -999   26.9
>  0.2
> 0506010300   0.00   22.0  223.2   37.7   -999   64.3   -999   -999   28.0
>  0.2
>
> ______________________________________________
> R-help at 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.
>



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

What is the problem that you are trying to solve?



More information about the R-help mailing list