table_neat {neatStats} | R Documentation |
Table, descriptives
Description
Creates a neat means (or similar descriptives) and standard
deviations table, using aggr_neat
functions as arguments.
Alternatively, merges and transposes data frames into rows.
Usage
table_neat(
values_list,
group_by = NULL,
group_per = "rows",
to_clipboard = FALSE,
method = "mean+sd",
transpose = FALSE
)
Arguments
values_list |
Data frames as returned from the |
group_by |
String, or vector of strings: the name(s) of the column(s) in
the |
group_per |
String, "rows" or "columns". If set to "columns" (or just "c" or "col", etc.), each column contains statistics for one group. Otherwise (default), each row contains statistics for one group. |
to_clipboard |
Logical. If |
method |
Function or string; overwrites the |
transpose |
Logical (default: |
Details
The values
, round_to
, and new_name
arguments
given in the aggr_neat
function are always applied. However,
the prefix
parameter will be overwritten as NULL
. If
new_name
in aggr_neat
is NULL
, the given input
variable names will be used instead of "aggr_value"
. Furthermore,
the group_by
or method
given in the aggr_neat
function are only applied when no arguments are given in the
table_neat
function for the identical parameters
(group_by
or medians
). If either parameter is given in the
table_neat
function, all separately given respective
argument(s) in the aggr_neat
function(s) are ignored.
Value
Returns a data frame with means or medians and SDs per variable and per group.
See Also
aggr_neat
for more related details
Examples
data("mtcars") # load base R example dataset
# overall means and SDs table for disp (Displacement) and hp (Gross horsepower)
table_neat(list(aggr_neat(mtcars, disp),
aggr_neat(mtcars, hp)))
# means and SDs table for mpg (Miles/(US) gallon), wt (Weight), and hp (Gross horsepower)
# grouped by cyl (Number of cylinders)
# each measure rounded to respective optimal number of digits
# wt renamed to weight (for the column title)
table_neat(list(
aggr_neat(mtcars, mpg, round_to = 1),
aggr_neat(mtcars, wt, new_name = 'weight', round_to = 2),
aggr_neat(mtcars, hp, round_to = 0)
),
group_by = 'cyl')
# same as above, but with medians, and with groups per columns
table_neat(
list(
aggr_neat(mtcars, mpg, round_to = 1),
aggr_neat(mtcars, wt, new_name = 'weight', round_to = 2),
aggr_neat(mtcars, hp, round_to = 0)
),
group_by = 'cyl',
method = 'median+sd',
group_per = 'columns'
)
# an extensive example to show how to collect and aggregate raw data is
# available via the README file at the repository:
# https://github.com/gasparl/neatstats