Learn R Programming

imp4p (version 1.2)

fast_apply_sd_na_rm_T: Function similar to the function apply(X,dim,sd,na.rm=TRUE).

Description

This function is similar to the function apply(X,dim,sd,na.rm=TRUE) but written thanks to the Rcpp package and therefore faster than apply(X,dim,sd,na.rm=TRUE).

Usage

fast_apply_sd_na_rm_T(X, dim)

Arguments

X

A data matrix containing numeric and missing values.

dim

A numeric value: 1 if the standard deviation has to be computed for each row of X, or 2 if the standard deviation has to be computed for each column of X.

Value

A numeric vector containing the standard deviation of observed values in either each row or each column of X.

Examples

Run this code
# NOT RUN {
## The function is currently defined as
##function (X, dim)
##{
##    .Call("imp4p_fast_apply_sd_na_rm_T", 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_sd_na_rm_T(res.sim$dat.obs, 1),
##           apply(res.sim$dat.obs,1,sd,na.rm=TRUE))
# }

Run the code above in your browser using DataLab