[R] Problems with a specific calculate.

Toni López Mayol tonimayol_1f at hotmail.com
Tue Oct 19 12:38:55 CEST 2010


Hello friends of R, 

My name is Toni, i'm 25 and I'm working on the Meteorological Investigation team from Balearic Islands.

I had contact to you because I have a problem:

I done a file for every day since 1912 about precipitation. That file has the following structure:

> str(Ast)
Loading required package: sp
Formal class 'SpatialPixelsDataFrame' [package "sp"] with 7 slots
  ..@ data       :'data.frame':	499105 obs. of  2 variables:
  .. ..$ PRECIP.pred: num [1:499105] 0.000536 0.000536 0.000536 0.000536 0.000536 ...
  .. ..$ PRECIP.var : num [1:499105] 1.90e-05 1.90e-05 1.90e-05 1.90e-05 1.90e-05 ...
  ..@ coords.nrs : num(0) 
  ..@ grid       :Formal class 'GridTopology' [package "sp"] with 3 slots
  .. .. ..@ cellcentre.offset: Named num [1:2] 345 4278
  .. .. .. ..- attr(*, "names")= chr [1:2] "x" "y"
  .. .. ..@ cellsize         : Named num [1:2] 0.1 0.1
  .. .. .. ..- attr(*, "names")= chr [1:2] "x" "y"
  .. .. ..@ cells.dim        : Named int [1:2] 2684 1600
  .. .. .. ..- attr(*, "names")= chr [1:2] "x" "y"
  ..@ grid.index : int [1:499105] 2468192 2468193 2468194 2468195 2465507 2465508 2465509 2465510 2465511 2465512 ...
  ..@ coords     : num [1:499105, 1:2] 505 505 505 505 505 ...
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : NULL
  .. .. ..$ : chr [1:2] "x" "y"
  ..@ bbox       : num [1:2, 1:2] 345 4278 614 4438
  .. ..- attr(*, "dimnames")=List of 2
  .. .. ..$ : chr [1:2] "x" "y"
  .. .. ..$ : chr [1:2] "min" "max"
  ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
  .. .. ..@ projargs: chr "+proj=utm +zone=31 +units=km"

This is a single file for one specific day. 

Now, I must to sum the precipitation of every day from every file like this.

I must to do the annual precipitation for every year.

How can I take the precipitation ( PRECIP.pred) of every day and sum it with all at same time? maybe a loop?

Thanks so much for your time.

Toni


More information about the R-help mailing list