summaryPlumes: Summarise values of Simulations by plumes

Description Usage Arguments Details Value Author(s) Examples

View source: R/summaryPlumes.R

Description

This function is similar to apply for the values of Simulations plume-wise. It takes a function and returns a vector with a value for each plume: the result of the function applied to all values belonging to this plume. As values may be too big to keep in memory, the function is applied chunk-wise; therefore it only works for associative functions. A (slower) method without this restriction is It is combined with a global summary function and thus provides a general basic form of a cost function.

Usage

1
2
3
4
5
6
7
summaryPlumes(simulations,
  locations = 1:nLocations(simulations), 
  plumes = 1:nPlumes(simulations), 
  kinds = 1, 
  fun, summaryFun = weightedMean,
  weight = 1, na.rm = FALSE, ...)
weightedMean(x, weight, 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; multiple are ignored

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), be associative, i.e. fun(c(a,b)) = fun(c(fun(a),b)), work also on vectors of length 0 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

x

vector

Details

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

summaryPlumes

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

Author(s)

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
data(radioactivePlumes) 
# sample of locations, e.g. proposed sensor set
locSample = sample.int(nLocations(radioactivePlumes), 10) 

# plume detection 
# (number of plumes not detected at any of locSample at a level of more than 1e-7)
plumeMin_radioactivePlumes = 
  summaryPlumes(radioactivePlumes, locations = locSample, kinds = 2, 
  fun = "min",
  summaryFun = function(x, weight = 1, na.rm = TRUE){sum(x < 1e-7)})

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