stats0: Descriptive Statistics for a Vector or a Data Frame

Description Usage Arguments Value Author(s) See Also Examples

Description

Applies descriptive statistics to a vector or a data frame. The function stats0 is a general function. This function is used for extending the basic descriptive statistics functions from the base and stats package. The function prop_miss computes the proportion of missing data for each variable.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
stats0(x, FUN, na.rm=TRUE,...)

max0(x, na.rm=TRUE)
mean0(x, na.rm=TRUE)
min0(x, na.rm=TRUE)
quantile0(x, probs = seq(0, 1, 0.25), na.rm=TRUE)
sd0(x, na.rm=TRUE)
var0(x, na.rm=TRUE)

prop_miss(x)

Arguments

x

Vector or a data frame

FUN

Function which is applied to x

na.rm

Logical indicating whether missing data should be removed

probs

Probabilities

...

Further arguments to be passed

Value

A vector or a matrix

Author(s)

Alexander Robitzsch

See Also

base::max, base::mean, base::min, stats::quantile, stats::sd, stats::var

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#############################################################################
# EXAMPLE 1: Descriptive statistics toy datasets
#############################################################################	

#--- simulate vector y and data frame dat
set.seed(765)
N <- 25    # number of observations
y <- stats::rnorm(N)
V <- 4    # number of variables
dat <- matrix( stats::rnorm( N*V ) , ncol=V )
colnames(dat) <- paste0("V",1:V)

#-- standard deviation
apply( dat , 2 , stats::sd )
sd0( dat )
#-- mean
apply( dat , 2 , base::mean )
mean0( dat )
#-- quantile
apply( dat , 2 , stats::quantile )
quantile0( dat )
#-- minimum and maximum
min0(dat)
max0(dat)

#*** apply functions to missing data
dat1 <- dat
dat1[ cbind( c(2,5) ,2) ] <- NA

#-- proportion of missing data
prop_miss( dat1 )
#-- MAD statistic
stats0( dat , FUN = stats::mad )
#-- SD
sd0(y)


Search within the miceadds package
Search all R packages, documentation and source code

Questions? Problems? Suggestions? or email at ian@mutexlabs.com.

Please suggest features or report bugs with the GitHub issue tracker.

All documentation is copyright its authors; we didn't write any of that.