Description Usage Arguments Details Author(s) Examples
Function for creating summary tables of factors and numeric columns in a survey.
You can also group the survey by other variables before passing it to survey_table
to get scores/proportions by one or more variables.
1 2 3 4 5 |
srv |
A survey object. |
... |
Columns to summarise. Accepts either numeric or factors, and a warning will be issued if it encounters text etc. When creating a table for factors, they must all have identical factor levels. |
wide |
If this is |
weight |
When |
question |
When |
filter_missing |
Set to |
filter_response |
When set to |
contrast |
Set to |
The function does the following:
average
Produces an average for the tables, which is always the
average for the first group (as set by group_by
),
and it is appropriately grouped for the remaining groups.
weight
Unless otherwise specified, this function will always
weight the results for the average. This also means that the function requires
that the weight column (w
) is present in the data.
filter
Filters missing values NA
for all groups and the variables that go into the table, as well as
percent_missing
which exceeds the cutoff in the surveys config. Setting
filter_missing
to FALSE
overrides the filtering of percent_missing
,
while setting filter_response
to FALSE
does the same for filtering of
response variables.
count
For both numeric and factor variables, this function always provides a count for the number of valid observations (after filtering) in each group. This count is not weighted. (Only the proportions themselves.)
missing
Turns implicit missing values into
explicit missing values. When this is the case, counts will be 0 and
the aggregated values will be NA
(unless it is a factor and one of the
other proportions are not NA, in this case, the proportions are set to 0 instead.)
spread
When wide
is set to TRUE
, the function
spreads the results to a wide format. For numeric, the variables are put in
separate columns. For factor variables, the proportions are
spread by their respective levels (e.g. "Yes", "No" etc become columns.)
An exception is made when grouping by several variables and there is only
one response variable (numeric).)
Kristian D. Olsen
1 | x %>% group_by(q7_service) %>% survey_table(image:loyal)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.