aggregation function needed if variables do not
identify a single observation for each output cell. Defaults to length
(with a message) if needed but not specified.
...
further arguments are passed to aggregating function
margins
vector of variable names (can include "grand_col" and
"grand_row") to compute margins for, or TRUE to compute all margins .
Any variables that can not be margined over will be silently dropped.
subset
quoted expression used to subset data prior to reshaping,
e.g. subset = .(variable=="length").
fill
value with which to fill in structural missings, defaults to
value from applying fun.aggregate to 0 length vector
drop
should missing combinations dropped or kept?
value.var
name of column which stores values, see
guess_value for default strategies to figure this out.
Details
The cast formula has the following format:
x_variable + x_2 ~ y_variable + y_2 ~ z_variable ~ ...
The order of the variables makes a difference. The first varies slowest,
and the last fastest. There are a couple of special variables: "..."
represents all other variables not used in the formula and "." represents
no variable, so you can do formula = var1 ~ ..
Alternatively, you can supply a list of quoted expressions, in the form
list(.(x_variable, x_2), .(y_variable, y_2), .(z)). The advantage
of this form is that you can cast based on transformations of the
variables: list(.(a + b), (c = round(c))). See the documentation
for . for more details and alternative formats.
If the combination of variables you supply does not uniquely identify one
row in the original data set, you will need to supply an aggregating
function, fun.aggregate. This function should take a vector of
numbers and return a single summary statistic.