Factor level frequencies Cell FUN.

Description

For calculating frequencies or proportions of a certain level from factor x.

Usage

1
2
      eventpct_cell(x, y, z, w, cell_ids, row_ids, col_ids, vnames, vars, n_min,
      digits=1, digits2=0, event=2, type=1)

Arguments

x

The factor x for calculations

y

NOT USED

z

NOT USED

w

Weights for x factor. Only if calculating weigted frequences.

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 decimal places (percentages)

digits2

Integer indicating the number of decimal places (N, needed if N is not integer because of weighting)

event

The Number of factor level to calculate frequencies. from 1 to nlevels(x)

type

Type of representation, one of following.

  • 1, pct (n)

  • 2, n (pct)

  • 3, pct

  • 4, n

  • 5, pct (n/N)

Author(s)

ADES <ades-s@web.de>

Examples

1
2
3
4
5
6
7
8
9
sex     <- factor(rbinom(1000, 1, 0.4), labels=c('Men', 'Women'))
event   <- factor(rbinom(1000, 1, 0.1), labels=c('no',  'yes'))
decades <- rbinom(1000, 3, 0.5)
decades <- factor(decades, labels=c('[35,45)','[45,55)','[55,65)','[65,75)'))
d<-data.frame(sex, decades, event)
tabular.ade(x_vars=c('event'), xname=c('Event'),
   rows=c('sex','ALL'), rnames=c('Gender'),
   cols=c('decades', 'ALL'),   cnames=c('Age decades'),
   data=d, FUN=eventpct_cell)