| freq.tables {heR.Misc} | R Documentation |
Return flat frequency tables in a convenient dataframe format
freq.tables(x, tablespecs, latex = FALSE, file = "")
x |
a dataframe containing raw numeric data |
tablespecs |
a tablespecs object with data and table specifications, see below. |
latex |
logical, whether to write a LaTeX file or not |
file |
the file to which LaTeX-format data will be written, if empty then the table will be written to standard output |
For each response variable in tablespecs, one table is generated across
all key variables. The tablespecs object
contains all variable, label, etc. specifications for the
table. These include the following:
The variables are cut into intervals with the cut function,
with right=TRUE/FALSE depending on the tablespecs value
and according to the breaks given the response.cuts or key.cuts
values. A value of NA means the variable will not be cut. All
variables are converted to factors, whether or not they are cut.
Labels for binary variables (i.e., those having only 0's and 1's) are set
to TRUE and FALSE values.
Important Note: The user must check to make sure the specified cuts
cover the range of variable values of interest, because values not within the
specified breaks will be assigned NA values during the factoring process.
The frequency table is returned as a probability table if prob is TRUE.
If latex=TRUE, then the tables are printed in LaTeX format
although the ftable dataframe object(s) is(are) also returned. If
file != "", then the LaTeX output will be written to the named file
with one table appended after another.
This function calls ftable and converts the output format
to a dataframe format for easy storage and conversion to LaTeX or HTML, e.g.,
using the xtable function.
a dataframe containing a flattened frequency table and associated factors
Neil Klepeis