Learn R Programming

specmine (version 4.0.0)

remove_data: Remove data

Description

Removes selected samples, data variables, or metadata variables from a dataset.

Usage

remove_data(
  dataset,
  data.to.remove,
  type = "sample",
  by.index = FALSE,
  rebuild.factors = TRUE
)

Value

A dataset object with the same overall structure as the input, where the requested samples, data variables, or metadata variables have been removed according to `type`.

Arguments

dataset

Dataset to modify.

data.to.remove

Data to remove.

type

One of "sample", "data", or "metadata".

by.index

Logical. If TRUE, data.to.remove has indexes.

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 = c("A", "B", "A"), row.names = c("s1", "s2", "s3"))
dataset <- list(data = data, metadata = metadata)
remove_data(dataset, "s2", type = "sample")

Run the code above in your browser using DataLab