summaryLocations: Summarise values of Simulations by locations

Description Usage Arguments Details Value Author(s) Examples

View source: R/summaryLocations.R

Description

This function is similar to apply for the values of Simulations location-wise. It takes a function and returns a vector with a value for each location: the result of the function applied to all values belonging to this location. This can be useful to generate maps.

Usage

1
2
3
4
5
6
summaryLocations(simulations, 
  locations = 1:nLocations(simulations), 
  plumes = 1:nPlumes(simulations), 
  kinds = 1, 
  fun, summaryFun = weightedMean, 
  weight = 1, na.rm = FALSE, ...)

Arguments

simulations

Simulations

locations

indices of locations to be taken into account (to apply the function to a subset of simulations); for invalid indices NA values are used

plumes

indices of plumes to be taken into account; for invalid indices NA values are used

kinds

index of kind of values to be taken into account; only one kind can be used, all but the first given index are ignored

fun

function to be applied; it must have a single parameter (vector) and return a single value; in addition it needs a parameter na.rm or ...; possible choices are sum, prod, max, min

summaryFun

function to summarise the plume-wise results (as first parameter) to a global value; by default it is a weighted mean; in addition it can have the parameters weight, or use ...

weight

to be used by summaryFun: either a numeric value of length 1 or same length as plumes or a character indicating a column of the data associated with the plumes of simulations

na.rm

logical how to treat missing values by fun (has no influence on summaryFun)

...

further arguments to be forwarded to fun or summaryFun

Details

summaryLocations is similar to summaryPlumes but is not restricted to associative functions. For a more general function see simulationsApply. To use a different summaryFun you may use replaceDefault with kind = "summaryFun.summaryPlumes" to check the function beforehand or to generate it by resetting the default parameters of an existing function.

Value

A list of

summary

the result of summaryFun

summaryLocations

the location-wise results of fun, one value for each selected location

Author(s)

Kristina B. Helle, kristina.helle@uni-muenster.de

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
data(radioactivePlumes) 
plumeSample =  c(1:5, 16:20, 30:34, 45:49)# sample of plumes: jan, apr, jul, oct

# plume detection 
# (number of plumes in plumeSample that can be detected at a level of more than 1e-7)
detection1em7 = function(x, ...){
  xExceed = x > 1e-7
  out = sum(xExceed)
  return(out)
}
plumeNr_radioactivePlumes = 
  summaryLocations(radioactivePlumes, 
                   plumes = plumeSample, fun = detection1em7, kinds = 2)
## plot map
plumeNrMap = radioactivePlumes@locations
plumeNrMap@data$plumeNr = plumeNr_radioactivePlumes[["summaryLocations"]]
spplot(plumeNrMap, zcol = "plumeNr")

sensors4plumes documentation built on May 1, 2019, 10:27 p.m.