mean_sd_cell: Mean and SD Cell FUN

Description Usage Arguments Author(s) Examples

View source: R/mean_sd_cell.R

Description

To calculate mean and SD or weighted mead and SD.

Usage

1
2
mean_sd_cell(x, y, z, w, cell_ids, row_ids, col_ids, vnames, vars, n_min,
             digits = 3, style=1, nsd=1)

Arguments

x

The x variable for calculations

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

NOT USED

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.

style

Type of representation.

  • 1. mean (sd)

  • 2. mean (mean-sd*nsd, mean+sd*nsd)

  • 3. mean plus-minus sd

nsd

Multiplier for sd in stlyle 2. (for normal distribution )

  • nsd=1 –> 68.27 % values

  • nsd=1.645 –> 90 % values

  • nsd=1.96 –> 95 % values

  • nsd=2 –> 95.45 % values

  • nsd=2.575 –> 99 % values

  • nsd=3 –> 99.73 % values

Author(s)

ADES <[email protected]>

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
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]'),
   rows=c('sex','ALL'), rnames=c('Gender'),
   cols=c('decades'),   cnames=c('Age decades'),
   data=d, FUN=mean_sd_cell, style=2, nsd=1.96)

etable documentation built on May 29, 2017, 9:45 a.m.