Frequency Cell FUN

Description

For calculating relative or absolute frequencies.

Usage

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

Arguments

x

The x variable (can be easy 1:N if no missings)

y

NOT USED

z

NOT USED

w

Weights for x variable. Only if calculating weigted frequences.

cell_ids

Index vector for selecting values in cell.

row_ids

Index vector for selecting values in row.

col_ids

Index vector for selecting values in col.

vnames

NOT USED

vars

NOT USED

n_min

NOT USED

digits

Integer indicating the number of decimal places (N)

digits2

Integer indicating the number of decimal places (percent)

type

Type of frequencies, one of following.

  • n, Number in cell.

  • pct, Overall percentages.

  • pctn, Overall percentages and n.

  • rowpct, Percentages of rows.

  • colpct, Percentages of cols.

  • rowpctn, Percentages of rows and n.

  • colpctn, Percentages of cols and n.

  • all, Overall, row, col percentages.

Details

The function calculate frequencies for cell. If x has no missings the frequencies are independent from x.

Author(s)

ADES <ades-s@web.de>

Examples

1
2
3
4
5
6
7
sex     <- factor(rbinom(1000, 1, 0.4),  labels=c('Men', 'Women'))
decades <- rbinom(1000, 3, 0.5)
decades <- factor(decades, labels=c('[35,45)','[45,55)','[55,65)','[65,75)'))
d<-data.frame(sex, decades)
tabular.ade(x_var='sex',  rows=c('sex',     'ALL'), rnames=c('Gender'),
                          cols=c('decades', 'ALL'), cnames=c('Age decades'),
            data=d, FUN=n_cell, , type="all")