Learn R Programming

metan (version 1.7.0)

utils_na: Utilities for handling with NA values

Description

  • has_na(): Check for NA values in the data and return a logical value.

  • random_na(): Generate random NA values in a two-way table based on a desired proportion.

  • remove_cols_na(): Remove columns with NA values.

  • remove_rows_na(): Remove rows with NA values.

  • select_cols_na(): Select columns with NA values.

  • select_rows_na(): Select rows with NA values.

  • replace_na() Replace missing values

Usage

remove_rows_na(.data, verbose = TRUE)

remove_cols_na(.data, verbose = TRUE)

select_cols_na(.data, verbose = TRUE)

select_rows_na(.data, verbose = TRUE)

has_na(.data)

replace_na(.data, ..., replace = 0)

random_na(.data, prop)

Arguments

.data

A data frame or tibble

verbose

Logical argument. If TRUE (default) shows in console the rows or columns deleted.

...

Variables to replace NAs. If ... is null then all variables with NA will be replaced. It must be a single variable name or a comma-separated list of unquoted variables names. Select helpers are also allowed.

replace

The value used for replacement. Defaults to 0. Use replace = "colmeans" to replace missing values with colum means.

prop

The proportion (percentage) of NA values to generate in .data.

Value

A data frame with rows or columns with NA values deleted.

Examples

Run this code
# NOT RUN {
library(metan)
data_with_na <- data_g
data_with_na[c(1, 5, 10), c(3:5, 10:15)] <- NA
data_with_na
has_na(data_with_na)
remove_cols_na(data_with_na)
remove_rows_na(data_with_na)
select_cols_na(data_with_na)
select_rows_na(data_with_na)
replace_na(data_with_na)
# }

Run the code above in your browser using DataLab