Learn R Programming

specmine (version 4.0.0)

remove_variables_by_nas: Remove variables by NAs

Description

Removes variables with too many missing values.

Usage

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

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`.

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.

Examples

Run this code
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)

Run the code above in your browser using DataLab