[R] Problems with a specific calculate.
David Winsemius
dwinsemius at comcast.net
Tue Oct 19 20:26:12 CEST 2010
On Oct 19, 2010, at 6:38 AM, Toni López Mayol wrote:
> 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 you do that will depend on the data structure in which these Ast
objects will be assembled. It sounds as though they might be in
separate files roughly 100*365 in number and with different names that
have their dates in some sort of meaningful format?
>
> How can I take the precipitation ( ) of every day and sum it with
> all at same time? maybe a loop?
A single day total with your current object might be:
s.pred.precip <- sum( Ast at data$PRECIP.pred )
s.pred.precip
>
> Thanks so much for your time.
>
> Toni
> ______________________________________________
> 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.
David Winsemius, MD
West Hartford, CT
More information about the R-help
mailing list