itremove: Iteratively removes all rows and columns of a matrix or...

Description Usage Arguments Details Value Examples

Description

Iteratively removes all rows and columns of a matrix or dataframe with less than a given number of non zero elements

Usage

1
itremove(x, minnumber = NA, cmin = NA, rmin = NA)

Arguments

x

matrix or data.frame. Table with only numeric values.

minnumber

integer. A number of minimum non zero elements. How many values > 0 have to be present to consider a row/column sufficiently linked to perform further analysis? Every column with less values > 0 will be removed. Either minnumber or cmin and rmin must be given.

cmin

integer. Same as minnumber, but specifically for columns.

rmin

integer. Same as minnumber, but specifically for rows.

Details

A matrix or data.frame with numeric values often contains rows and columns with an insufficient amount of values > 0 for a certain task. For example correspondence analysis or bivariate correlation analysis requires a minimum amount of usable values. In an archaeological context this could apply for example, if certain find categories are particularly rare in a burial site context.

delrc allows to remove rows and columns, that don't fulfill the requirements.

Value

A matrix or dataframe with all rows and columns removed that had less than the given number of non zero elements. If minnumber or cmin and rmin are too restrictive and no content remains in the table, than the result is NA.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
testmatrix <- data.frame(
c1 = c(0,3,8,2),
c2 = c(0,6,7,0),
c3 = c(0,0,0,0),
c4 = c(0,3,8,2),
c5 = c(0,6,7,0),
c6 = c(1,0,0,1)
)

# The following code removes every column with less than 3 values > 0.
# That will remove the columns c2, c3, c5 and c6.
# Further, every row with less than 2 values gets removed.
# That will delete row 1.
itremove(testmatrix, cmin = 3, rmin = 2)

MartinHinz/quantaar documentation built on May 7, 2019, 3:37 p.m.