Learn R Programming

arkhe (version 0.3.1)

remove: Data Cleaning

Description

Removes empty row/column or row/column with missing values or zeros.

Usage

remove_NA(x, ...)

remove_empty(x, ...)

remove_zero(x, ...)

# S4 method for matrix remove_NA(x, margin = 1, finite = TRUE)

# S4 method for matrix remove_zero(x, margin = 1)

# S4 method for matrix remove_empty(x, margin = 1)

Arguments

x

A matrix, a data.frame or a *Matrix object.

...

Currently not used.

margin

An integer giving the subscript which the cleaning will be applied over (1 indicates rows, 2 indicates columns).

finite

A logical scalar: should non-finite values also be removed?

See Also

Other utilities: replace()

Examples

Run this code
# NOT RUN {
## Create a count data matrix
X <- CountMatrix(sample(1:10, 25, TRUE), nrow = 5, ncol = 5)
k <- sample(1:25, 3, FALSE)

## Add zeros
X[k] <- 0L
## Remove row with zeros
remove_zero(X, margin = 1)
## Remove column with zeros
remove_zero(X, margin = 2)

## Add NA
X[k] <- NA
## Remove row with zeros
remove_NA(X, margin = 1)
## Remove column with zeros
remove_NA(X, margin = 2)
# }

Run the code above in your browser using DataLab