Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

check_data

Search for variables with zero range in a matrix


Description

Search for variables with zero range in a matrix.

Usage

check_data(x, ina = NULL)

Arguments

x

A matrix or a data.frame with the data, where rows denotes the observations and the columns contain the dependent variables.

ina

If your data are grouped, for example there is a factor or numerical variable indicating the groups of the data supply it here, otherwise leave it NULL.

Details

The function identifies the variabels with zero range, instead of a zero variance as this is faster. It will work with matrices and data.frames.

Value

A numerical vector of length zero if no zero ranged variable exists, or of length at least one with the index (or indices) of the variable(s) that need attention or need to be removed.

Author(s)

Michail Tsagris

R implementation and documentation: Michail Tsagris <mtsagris@yahoo.gr> and Manos Papadakis <papadakm95@gmail.com>.

See Also

Examples

x <- matrix( rnorm(100 * 100), ncol = 100 )
res<-check_data(x)

## some variables have a constant value
x[, c(1,10, 50, 70)] <- 1
res<-check_data(x)
id <- rep(1:4, each = 25 )
x[1:25, 2] <- 0
res<-check_data(x)  ## did not use the id variable
res<-check_data(x, id)  ## see now
x <- NULL

Rfast

A Collection of Efficient and Extremely Fast R Functions

v2.0.1
GPL (>= 2.0)
Authors
Manos Papadakis, Michail Tsagris, Marios Dimitriadis, Stefanos Fafalios, Ioannis Tsamardinos, Matteo Fasiolo, Giorgos Borboudakis, John Burkardt, Changliang Zou, Kleanthi Lakiotaki and Christina Chatzipantsiou.
Initial release
2020-09-13

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.