stat_cell {etable} | R Documentation |
Diverse statistics cell function
Description
Calculating values of several descriptive statistics.
Usage
stat_cell(x, y, z, w, cell_ids, row_ids, col_ids, vnames, vars, n_min,
digits = 3, digits2=1)
Arguments
x |
The x variable |
y |
NOT USED |
z |
NOT USED |
w |
Weights for x variable. |
cell_ids |
Index vector for selecting values in cell. |
row_ids |
NOT USED |
col_ids |
NOT USED |
vnames |
NOT USED |
vars |
A vector of character strings with names of variables in data.frame for x, y and z. Use names of x or y as keywords, to choose a certain statistic. |
n_min |
Minimum n in the cell for useful calculation. Cells with n<n_min deliver no output. |
digits |
Integer indicating the number of significant digits. |
digits2 |
Integer indicating the number of decimal places for percentages. |
Details
Keywords are:
N: number in this cell
MIN: minimum
MAX: maximum
SUM: sum
MEAN: mean
SD: standard deviation
MSD: mean, standard deviation
MCI: mean, 95% CI
VAR: variance
MEDIAN: median
MD: mean deviation from the mean (*1.253)
MAD: median absolute deviation (*1.4826)
IQR: interquartile range
MQQ: median (Q1/Q3)
PROP: proportion
POP: proportion of level 2 (only binar)
PCI: proportion of level 2, 95% CI
RANGE: range
CV: coefficient of variation
MODE: mode
MISS: number of missing values
PNM: proportion of non missing values
COMB: POP for binar and MQQ for continues
SKEW: skewness
KURT: excess kurtosis
GEO: geometric mean
HARM: harmonic mean
TM1: truncated mean 1%
TM5: truncated mean 5%
TM10: truncated mean 10%
TM25: truncated mean 25%
WM1: winsorized mean 1%
WM5: winsorized mean 5%
WM10: winsorized mean 10%
WM25: winsorized mean 25%
M1SD: mean-SD, mean+SD
M2SD: mean-2SD, mean+2SD
M3SD: mean-3SD, mean+3SD
MM1SD: mean, mean-SD, mean+SD
MM2SD: mean, mean-2SD, mean+2SD
MM3SD: mean, mean-3SD, mean+3SD
NORM50: mean-0.675SD, mean+0.675SD
NORM90: mean-1.645SD, mean+1.645SD
NORM95: mean-1.96SD, mean+1.96SD
NORM99: mean-2.576SD, mean+2.576SD
P1: 1th quantile
P2.5: 2.5th quantile
P5: 5th quantile
P10: 10th quantile
P20: 20th quantile
P25: 25th quantile
P30: 30th quantile
P40: 40th quantile
P50: 50th quantile
P60: 60th quantile
P70: 70th quantile
P75: 75th quantile
P80: 80th quantile
P90: 90th quantile
P95: 95th quantile
P97.5: 97.5th quantile
P99: 99th quantile
Author(s)
Andreas Schulz <ades-s@web.de>
Examples
sex <- factor(rbinom(1000, 1, 0.4), labels=c('Men', 'Women'))
height <- rnorm(1000, mean=1.66, sd=0.1)
height[which(sex=='Men')]<-height[which(sex=='Men')]+0.1
weight <- rnorm(1000, mean=70, sd=5)
decades <- rbinom(1000, 3, 0.5)
decades <- factor(decades, labels=c('[35,45)','[45,55)','[55,65)','[65,75)'))
d<-data.frame(sex, decades, height, weight)
tabular.ade(x_vars=c('height', 'weight'), xname=c('Height [m]','Weight [kg]'),
y_vars=c('N', 'MEAN', 'SD', 'SKEW', 'KURT'),
rows=c('sex', 'ALL', 'decades', 'ALL'), rnames=c('Gender', 'Age decades'),
data=d, FUN=stat_cell)