select.colattrs.lsd {LSDinterface} | R Documentation |
Select a subset of a LSD results matrix (by variable attributes)
Description
This function select a subset of a LSD results matrix (as produced by read.raw.lsd
) by the variable attributes, considering the LSD object position and the time span.
Usage
select.colattrs.lsd( dataSet, info, col.names = NULL, init.value = NA,
init.time = NA, end.time = NA, posit = NULL,
posit.match = c( "fixed", "glob", "regex" ) )
Arguments
dataSet |
matrix produced by the invocation of |
info |
data frame produced by |
col.names |
a vector of optional names for the variables to select from. The default is to select from all variables. |
init.value |
initial value attributed to the variable(s) to select. |
init.time |
initial time attributed to the variable(s) to select. |
end.time |
end time attributed to the variable(s) to select. |
posit |
a string, a vector of strings or an integer vector describing the LSD object position of the variable(s) to select. If an integer vector, it should define the position of a SINGLE LSD object. If a string or vector of strings, each element should define one or more different LSD objects, so the returning matrix will contain variables from more than one object. By setting |
posit.match |
a string defining how the |
Details
Selection restriction arguments can be provided as needed; when not specified, all available cases are selected.
When posit
is supplied together with other attribute filters, the selection process is done in two steps. Firstly, the column names set by otter attribute filters are selected. Secondly, the instances defined by posit
are selected from the first selection set.
See also the read.XXXX.lsd
functions which may select just specific posit
object instances when loading LSD results. If only a single set of instances is required, this would be more efficient than using this function.
Value
Returns a single matrix containing the selected variables' time series contained in the original data set.
Note
If only variable names selection is needed, select.colnames.lsd
is more efficient because information pre-processing (info.details.lsd
) is not required.
Author(s)
Marcelo C. Pereira
See Also
list.files.lsd()
info.details.lsd()
,
select.colnames.lsd()
Examples
# get the list of file names of example LSD results
files <- list.files.lsd( system.file( "extdata", package = "LSDinterface" ) )
# read all instances of all variables of first file
bigTable <- read.raw.lsd( files[ 1 ] )
# build the info table
info <- info.details.lsd( files[ 1 ] )
# extract specific instances of a set of variables named '_A1p' and '_growth1'
abFirst2 <- select.colattrs.lsd( bigTable, info, c( "_A1p", "_growth1" ),
posit = c( "1_2", "1_5" ) )
print( abFirst2[ 50 : 60, ] )
# extract instances of variable '_A1p' that start at time step t = 1
# for the second and fourth objects under any top-level object (use globbing)
a24 <- select.colattrs.lsd( bigTable, info, "_A1p", init.time = 1,
posit = c( "*_2", "*_4" ), posit.match = "glob" )
print( a24[ 1 : 10, ] )
# extract all second-level object instances of all variables
aSec <- select.colattrs.lsd( bigTable, info, posit = "*_*", posit.match = "glob" )
print( aSec[ 1 : 10, ] )
# extract just top-level object instances variables
aTop <- select.colattrs.lsd( bigTable, info, posit = "^[0-9]+$",
posit.match = "regex" )
print( aTop[ 1 : 10, ] )