remove.na.strategies {tdata}R Documentation

Scenarios for Removing NAs

Description

Use this function to remove NA values from a matrix. This helps you to optimize the size of the information.

Usage

remove.na.strategies(
  data,
  countFun = function(nRows, nCols) nRows * nCols,
  rowIndices = NULL,
  colIndices = NULL,
  printMsg = FALSE
)

Arguments

data

A matrix that contains NA values.

countFun

A function to determine how strategies are sorted. The default function counts the number of observations. You might want to give columns a higher level of importance, for example, by using nRows*nCols^1.5.

rowIndices

The indices of the sorted rows to search. Use this to create jumps for a large number of rows (e.g., if the first sorted strategies suggest a small number of columns and you are looking for other strategies). Use NULL to disable it.

colIndices

Similar to rowIndices, but for columns.

printMsg

If TRUE, it prints the progress.

Details

When a matrix has NA values, one can omit columns with NA, rows with NA, or a combination of these two. The total number of observations is a function of the order. This function tries all combinations and returns the results.

Value

A list of lists, each with the following elements:

nRows

The number of rows in the matrix.

nCols

The number of columns in the matrix.

colRemove

The indices of the columns to be removed.

rowRemove

The indices of the rows to be removed.

Examples

data <- matrix(c(NA, 2, 3, 4, NA, 5, NA, 6, 7, NA, 9, 10, 11, 12, 13, 14, 15, NA, 16, 17), 4, 5)
res <- remove.na.strategies(data)

[Package tdata version 0.3.0 Index]