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

sumNAperGroup

Count number of NAs per sub-set of columns


Description

This function will count the number of NAs per group (defined by argument grp) while summing over all lines of a matrix or data.frame. The row-position has no influence on the counting. Using the argument asRelative=TRUE the result will be given as (average) number of NAs per row and group.

Usage

sumNAperGroup(x, grp, asRelative = FALSE)

Arguments

x

matrix or data.frame which may contain NAs

grp

factor describing which column of 'dat' belongs to which group

asRelative

(logical) return as count of NAs per row and group

Value

integer vector with count of NAs per group

See Also

NA, filter NAs by line presenceFilt

Examples

mat <- matrix(1:25, ncol=5) 
mat[lower.tri(mat)] <- NA
sumNAperGroup(mat, rep(1:2,c(3,2)))
sumNAperGroup(mat, rep(1:2,c(3,2)), asRelative=TRUE)

wrMisc

Analyze Experimental High-Throughput (Omics) Data

v1.5.4
GPL-3
Authors
Wolfgang Raffelsberger [aut, cre]
Initial release

We don't support your browser anymore

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