Learn R Programming

specmine (version 4.0.0)

remove_samples: Remove samples

Description

Removes samples from a dataset.

Usage

remove_samples(dataset, samples.to.remove, rebuild.factors = TRUE)

Value

A dataset object with the same structure as the input, with the selected samples removed from both `dataset$data` and `dataset$metadata`. If `rebuild.factors` is `TRUE`, unused factor levels in metadata are dropped.

Arguments

dataset

Dataset to modify.

samples.to.remove

Samples to remove.

rebuild.factors

Logical. If TRUE, rebuild factors in metadata.

Examples

Run this code
data <- matrix(
  1:9,
  nrow = 3,
  dimnames = list(c("x1", "x2", "x3"), c("s1", "s2", "s3"))
)
metadata <- data.frame(
  class = factor(c("A", "B", "A")),
  row.names = c("s1", "s2", "s3")
)
dataset <- list(data = data, metadata = metadata)
remove_samples(dataset, "s2")

Run the code above in your browser using DataLab