Learn R Programming

sensors4plumes (version 0.9.3)

subset.Simulations: Subsetting Simulations

Description

Return subsets of Simulations, subsetting by plumes, locations, the kinds of values or by the columns of data associated with plumes or locations -- possibly combined.

Usage

# S3 method for Simulations
subset(x, ..., locations, plumes, kinds, dataLocations, dataPlumes, 
  nameSave = NA, overwrite = FALSE, valuesOnly = FALSE)

Arguments

x

Simulations

...

parameters to be forwarded

locations

indices of locations to keep

plumes

indices of plumes to keep

kinds

indices of kinds of values to keep

dataLocations

indices of the data associated with the locations to keep

dataPlumes

indices of the data associated with the plumes to keep

nameSave

name for saving the new raster files for the values if they cannot be kept in memory (without suffix)

overwrite

logical if files may be overwritten by the raster files

valuesOnly

logical if only the subset of values is returned (if FALSE the result is the full new Simulations)

Value

A Simulations object, subsetted by the given indices: subsetting locations or plumes results in subsetting of the values. If the resulting raster is too big to keep in memory, it is saved.

If valuesOnly = TRUE, only the new values are returned, i.e. a raster object.

Details

Multiple or invalid values in locations and plumes are ignored, only the order is taken into account. (Because in SpatialIndexDataFrame and SpatialPolygridDataFrame no locations can be selected multiply.)

However, if valuesOnly = TRUE, multiplity is taken into account and invalid indices result in NA values. In this case only the values are returned.

Examples

Run this code
# NOT RUN {
## may create files
data(SimulationsSmall)

SimulationsSmall_a = subset(SimulationsSmall, locations = c(2,4,6,8))
SimulationsSmall_b = subset(SimulationsSmall, 
                            locations = 1:5, plumes = c(2,4), kinds = 1, 
                            dataPlumes = 1:2)
                            
# effect of 'valuesOnly'
data(radioactivePlumes)
locations1 = sample(nLocations(radioactivePlumes), 15)
plumes1 = sample(nPlumes(radioactivePlumes), 15)
subset_fm_RNA = subset(radioactivePlumes, 
                       plumes = c(plumes1, NA, 10000, NA, 0, plumes1), 
                       locations = c(locations1, NA, 10000, NA, 0,locations1))
                        
subset_mf_RNA_vO = subset(radioactivePlumes, 
                          plumes = c(plumes1, NA, 0, 10000, NA, plumes1), 
                          locations = c(locations1, NA, NA, 10000, 0, 0, locations1),
                          valuesOnly = TRUE)  
image(subset_fm_RNA@values) 
image(subset_mf_RNA_vO)   # with repetitions
# }

Run the code above in your browser using DataLab