Frequency Distribution Tables
Functions for creating and manipulating frequency tables of class
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
freqtab(x, ...) ## Default S3 method: freqtab(x, scales, items, design, na.rm = TRUE, ...) as.freqtab(x, scales, design, drop = FALSE, ...) ## S3 method for class 'table' freqtab(x, design, ...) ## S3 method for class 'freqtab' as.data.frame(x, row.names = NULL, optional = FALSE, drop = FALSE, ...) ## S3 method for class 'freqtab' head(x, ...) ## S3 method for class 'freqtab' tail(x, ...) scales(x, margin = 1) margin(x, margin = 1) margins(x) ## S3 method for class 'freqtab' droplevels(x, ...)
either an object (vector or
further arguments passed to or from other functions.
list of vectors containing the score scales for each score scale
list of vectors of column indices (numbers or column names)
with which total scores will be computed for
the equating design used in data collection. For univariate
logical with default
logical, with default
arguments passed to
integer vector specifying the margin(s) over which frequencies should be summed.
freqtab creates a frequency table from a vector or
of scores. When the
items argument is included, scores are assumed to
be item responses, which are summed to create total scores. The scores are
tabulated and stored as an array, with dimensions for each variable. Note
that in previous versions of the “
freqtab” class the frequency
table was stored as a
data.frame. This is no longer the case.
Instead, the table is stored as an array and converted to a
data.frame when printed or manipulated with the
as.data.frame converts an object of class “
x with any
unused factor levels, or levels with zero counts, removed.
x is an object of class “
simply modifies the attributes and converts to class
freqtab”. In this case,
x must already be structured
similar to a “
freqtab” object, with the first dimension
containing counts for total scores, and remaining dimensions containing
counts for one or more anchor tests.
as.freqtab converts a 'flat' contingency table (see
ftable) to class “
freqtab” with the appropriate
attributes. A flat contingency table is the
data.frame version of a
freqtab” object, where the first column contains the total
score scale, the last column contains counts, and the columns in between
contain different anchor test score combinations.
for class “
scales extracts the measurement scales for the variables specified in
margin = 1 referring to the total score scale,
and subsequent margins referring to anchor tests.
margin is a wrapper
margin.table, which itself is a simple wrapper for summing
over marginal counts, i.e.,
apply(x, margin, sum). And
returns the number of dimensions, i.e., score variables, in a frequency
design is used to set the dimnames of the frequency table, with
total2 used with single and counterbalanced groups,
anchor(s) used otherwise.
sets the design attribute, which is used in
The main difference between the “
freqtab” class and other
tabulation classes, like “
table” and “
is that the
dimnames, i.e., the score scales, are required to be
numeric. This facilitates plotting with
equate function, and descriptive statistics with the
summary.freqtab and other methods.
A table array with dimensions equal to the number of score scales.
In most cases, this will be a univariate or bivariate distribution, but
multivariate distributions are supported.
return numeric vectors.
Methods (by class)
default: Default method for a
data.frameof item responses, a
data.frameof total and anchor scores, or a vector of total scores.
table: Method for
Anthony Albano firstname.lastname@example.org
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
# Univariate distribution with score scale set.seed(2005) x <- round(rnorm(1000, 100, 10)) head(freqtab(x, scales = 70:130)) # Existing frequency table converted to class "freqtab" # The first score of zero, with zero counts, is dropped head(as.freqtab(ACTmath[, 1:2], drop = TRUE)) # Bivariate distribution # Reduce y to the anchor test margin (2) ny <- freqtab(x = KBneat$y, scales = list(0:36, 0:12)) margin(ny, margin = 2) # Summing scored item responses with the PISA data attach(PISA) r6items <- paste(items$itemid[items$clusterid == "r6"]) r7items <- paste(items$itemid[items$clusterid == "r7"]) pisa67 <- freqtab(students[students$book == 6, ], items = list(r6items, r7items), scales = list(0:16, 0:14)) detach(PISA) # Scales for both margins # Zero total score is unobserved scales(pisa67, 1:2) scales(droplevels(pisa67), 1:2)
Want to suggest features or report bugs for rdrr.io? Use the GitHub issue tracker.