Table of Contents
- Split a dataset into train and test dataset
A kind of
- The components must be vectors (numeric, character, or logical), factors, numeric matrices, lists, or other data frames.
- Matrices, lists, and data frames provide as many variables to the new data frame as they have columns, elements, or variables, respectively.
- Numeric vectors, logicals and factors are included as is, and by default18 character vectors are coerced to be factors, whose levels are the unique values appearing in the vector.
- Vector structures appearing as variables of the data frame must all have the same length, and matrix structures must all have the same row size.
 "data.frame"  "list"
subset(x, subset, select, drop = FALSE, …) reference
- For ordinary vectors
- the result is simply
x[subset & !is.na(subset)]
- For data frames
subsetargument works on the rows.
subsetwill be evaluated in the data frame, so columns can be referred to (by name) as variables in the expression.
- expression, indicating columns to select from a data frame.
- passed on to
[indexing operator. (like
x[r, vars, drop = drop])