fast_apply_nb_na: Function similar to the function...

Description Usage Arguments Value Author(s) Examples

View source: R/RcppExports.R

Description

This function is similar to the function apply(X,dim,function(x)sum(is.na(x))) but written thanks to the Rcpp package and therefore faster than apply(X,dim,function(x)sum(is.na(x))).

Usage

1

Arguments

X

A data matrix containing numeric and missing values.

dim

A numeric value: 1 if the number of missing values has to be computed for each row of X, or 2 if it has to be computed for each column of X.

Value

A numeric vector containing the number of missing values in either each row or each column of X.

Author(s)

Quentin Giai Gianetto <quentin2g@yahoo.fr>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## The function is currently defined as
##function (X, dim)
##{
##    .Call("imp4p_fast_apply_nb_na", PACKAGE = "imp4p", X, dim)
##  }
##
## You can compare the execution time with a traditional apply function by
## library(rbenchmark)
## res.sim=sim.data(nb.pept=2000,nb.miss=600);
## benchmark(fast_apply_nb_na(res.sim$dat.obs, 1),
##           apply(res.sim$dat.obs,1,function(x)sum(is.na(x))))
##
##
##

imp4p documentation built on Sept. 5, 2021, 5:38 p.m.