remove_variables_by_nas: Remove variables by NAs

View source: R/filter_dataset.R

remove_variables_by_nasR Documentation

Remove variables by NAs

Description

Removes variables with too many missing values.

Usage

remove_variables_by_nas(dataset, max.nas = 0, by.percent = FALSE)

Arguments

dataset

Dataset to modify.

max.nas

Maximum number of missing values allowed.

by.percent

Logical. If TRUE, max.nas is treated as a percentage.

Value

A dataset object with the same structure as the input, where variables whose number of missing values exceeds 'max.nas' have been removed from 'dataset$data'.

Examples

data <- matrix(
  c(1,  2, 3,
    NA, 5, NA,
    7,  8, 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_variables_by_nas(dataset, max.nas = 1)


specmine documentation built on Aug. 5, 2026, 5:06 p.m.