Learn R Programming

specmine (version 4.0.0)

subset_x_values: Subset x values

Description

Selects rows of the dataset by x values or by row index.

Usage

subset_x_values(dataset, variables, by.index = FALSE)

Value

A dataset object with the same structure as the input, where `dataset$data` contains only the selected variables or row indexes.

Arguments

dataset

Dataset to subset.

variables

Variables to keep.

by.index

Logical. If TRUE, variables are interpreted as row indexes.

Examples

Run this code
data <- matrix(
  1:9,
  nrow = 3,
  dimnames = list(c("10", "20", "30"), c("s1", "s2", "s3"))
)
metadata <- data.frame(group = c("A", "B", "A"), row.names = c("s1", "s2", "s3"))
dataset <- list(data = data, metadata = metadata)
subset_x_values(dataset, c("10", "30"))

Run the code above in your browser using DataLab