subsetDS {dsBase}R Documentation

Generates a valid subset of a table or a vector

Description

The function uses the R classical subsetting with squared brackets '[]' and allows also to subset using a logical oprator and a threshold. The object to subset from must be a vector (factor, numeric or charcater) or a table (data.frame or matrix).

Usage

subsetDS(
  dt = NULL,
  complt = NULL,
  rs = NULL,
  cs = NULL,
  lg = NULL,
  th = NULL,
  varname = NULL
)

Arguments

dt

a string character, the name of the dataframe or the factor vector and the range of the subset.

complt

a boolean that tells if the subset to subset should include only complete cases

rs

a vector of two integers that give the range of rows de extract.

cs

a vector of two integers or one or more characters; the indices of the columns to extract or the names of the columns (i.e. names of the variables to extract).

lg

a character, the logical parameter to use if the user wishes to subset a vector using a logical operator. This parameter is ignored if the input data is not a vector.

th

a numeric, the threshold to use in conjunction with the logical parameter. This parameter is ignored if the input data is not a vector.

varname

a character, if the input data is a table, if this parameter is provided along with the 'logical' and 'threshold' parameters, a subtable is based the threshold applied to the speicified variable. This parameter is however ignored if the parameter 'rows' and/or 'cols' are provided.

Details

If the input data is a table: The user specifies the rows and/or columns to include in the subset if the input object is a table; the columns can be refered to by their names. The name of a vector (i.e. a variable) can also be provided with a logical operator and a threshold (see example 3). If the input data is a vector: when the parameters 'rows', 'logical' and 'threshold' are all provided the last two are ignored ( 'rows' has precedence over the other two parameters then). If the requested subset is not valid (i.e. contains less than the allowed number of observations), the subset is not generated, rather a table or a vector of missing values is generated to allow for any subsequent process using the output of the function to proceed after informing the user via a message.

Value

a subset of the vector, matric or dataframe as specified is stored on the server side

Author(s)

Gaye, A.


[Package dsBase version 6.3.0 ]