For calculation of relative or absolute frequencies.
n_cell(x, y, z, w, cell_ids, row_ids, col_ids, vnames, vars, n_min,
digits=0, digits2=1, type="n")
The x variable (can be just 1:N if without missings values)
NOT USED
NOT USED
Weights for x variable. Only if calculating weigted frequences.
Index vector for selecting values in cell.
Index vector for selecting values in row.
Index vector for selecting values in col.
NOT USED
NOT USED
NOT USED
Integer indicating the number of decimal places (N)
Integer indicating the number of decimal places (percentages)
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.
The function calculate frequencies for cell. If x has no missing values the frequencies are independent of x. Missing values in x will be removed from calculation.
# NOT RUN {
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")
# }
Run the code above in your browser using DataLab