FormulaSums | R Documentation |
By default this function return sums if the formula contains a response part and a model matrix otherwise
FormulaSums(
data,
formula,
makeNames = TRUE,
crossTable = FALSE,
total = "Total",
printInc = FALSE,
dropResponse = FALSE,
makeModelMatrix = NULL,
sep = "-",
sepCross = ":",
avoidHierarchical = FALSE,
includeEmpty = FALSE,
NAomit = TRUE,
rowGroupsPackage = "base",
viaSparseMatrix = TRUE,
...
)
Formula2ModelMatrix(data, formula, dropResponse = TRUE, ...)
data |
data frame |
formula |
A model formula |
makeNames |
Column/row names made when TRUE |
crossTable |
Cross table in output when TRUE |
total |
String used to name totals |
printInc |
Printing "..." to console when TRUE |
dropResponse |
When TRUE response part of formula ignored. |
makeModelMatrix |
Make model matrix when TRUE. NULL means automatic. |
sep |
String to separate when creating column names |
sepCross |
String to separate when creating column names involving crossing |
avoidHierarchical |
Whether to avoid treating of hierarchical variables. Instead of logical, variables can be specified. |
includeEmpty |
When |
NAomit |
When |
rowGroupsPackage |
Parameter |
viaSparseMatrix |
When TRUE, the model matrix is constructed by a single call to |
... |
Further arguments to be passed to |
In the original version of the function the model matrix was constructed by
calling fac2sparse
repeatedly.
Now this is replaced by a single call to sparseMatrix
.
The sums are computed by calling aggregate
repeatedly.
Hierarchical variables handled when constructing cross table.
Column names constructed from the cross table.
The returned model matrix includes the attribute startCol
(see last example line).
A matrix of sums, a sparse model matrix or a list of two or three elements (model matrix and cross table and sums when relevant).
Øyvind Langsrud
ModelMatrix
x <- SSBtoolsData("sprt_emp_withEU")
FormulaSums(x, ths_per ~ year*geo + year*eu)
FormulaSums(x, ~ year*age*eu)
FormulaSums(x, ths_per ~ year*age*geo + year*age*eu, crossTable = TRUE, makeModelMatrix = TRUE)
FormulaSums(x, ths_per ~ year:age:geo -1)
m <- Formula2ModelMatrix(x, ~ year*geo + year*eu)
print(m[1:3, ], col.names = TRUE)
attr(m, "startCol")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.