The standard subset
function creates a subset based on one or more variables in the input data frame, which must be specified, and this is saved in the output data frame specified with an assignment statement. Given the focus on a single data frame within the lessR
system, the input data frame has a default value of the standard mydata
, and by default writes the revised data frame over the input data frame, without the need for an assignment statement. However, the behavior of the standard subset
function can be mimicked by setting save.dframerame=FALSE
.Also guidance and feedback regarding the subsets are provided by default. The first six lines of the input data frame are listed before the subset operation, followed by the first six lines of the output data frame.
To indicate retaining an observation, specify at least one variable name and the value of the variable for which to retain the corresponding observations, using two equal signs to indicate the logical equality. If no rows are specified, all rows are retained.
To indicate retaining a variable, specify at least one variable name. To specify multiple variables, separate adjacent variables by a comma, and enclose the list within the standard R combine function, c
. A single variable may be replaced by a range of consecutive variables indicated by a colon, which separates the first and last variables of the range. To delete a variable or variables, put a minus sign, -, in front of the c
.