peek_neat | R Documentation |
Cursory summaries and plots per group.
peek_neat(
dat,
values,
group_by = NULL,
filt = NULL,
sep = ", ",
collapse = NULL,
f_print = FALSE,
f_plot = NULL,
iqr_times = 3,
round_to = 4,
group_n = TRUE,
...
)
dat |
Data frame (or name of data frame as string). |
values |
String, or vector of strings: the name(s) of the column(s) in
the |
group_by |
String, or vector of strings: the name(s) of the column(s) in
the |
filt |
An expression to filter, by column values, the entire |
sep |
String (comma by default) for separating group names. |
collapse |
Decides how to handle multiple columns of |
f_print |
Printing function; see details. |
f_plot |
Plotting function; see details. (Provide string to skip plotting.) |
iqr_times |
The multiplication of IQR to calculate Tukey's fences, when
using default |
round_to |
Number of |
group_n |
Logical. If |
... |
Any arguments to be passed to the |
If set to TRUE
, prints to console the following data (per group):
mean
; 95
median
; quantile_1st
and quantile_3rd
(first and third
quantiles); "Tukey's fences" as fence_low
and fence_upp
; minimum
and maximum values (min
, max
); number of NA
s (na
).
Tukey's fences are the upper and lower limits with distances of X
times
the IQR
from the actual IQR, where X
is specified
via the iqr_times
parameter. Returns (invisibly) the same values,
unrounded, via a data frame. If alternative f_print
is given, prints
whatever value is returned from the given function (and attempts, if possible,
to create a data frame).
Creates and displays box plot(s) (per group) by default, along with overlayed
violin plot (densities proportionate to sample sizes). If alternative
f_plot
is given, the first argument will be the values per group, and
all plots will be arranged
into a single plot
and displayed together. To skip plotting, just give any character as argument
(e.g. "none"
or just ""
).
Data frame with the printed values (if possible).
data("mtcars") # load base R example dataset
# overall info for wt (Weight)
peek_neat(mtcars, 'wt', f_print = TRUE)
#'
# now groupped by cyl (Number of cylinders)
peek_neat(mtcars, 'wt', group_by = 'cyl')
# grouped by cyl and gear
peek_neat(mtcars,
'wt',
group_by = c('cyl', 'gear'),
f_print = TRUE)
# filter to only have cyl larger than 4
peek_neat(mtcars, 'wt', group_by = 'cyl', filt = cyl > 4)
# without plots
peek_neat(mtcars,
'wt',
group_by = 'cyl',
f_plot = "",
f_print = TRUE)
# with histogramms etc, using plot_neat
peek_neat(mtcars, 'wt', group_by = 'cyl', f_plot = plot_neat)
# with Q-Q plots, via ggpubr
peek_neat(mtcars,
'wt',
group_by = 'cyl',
f_plot = ggpubr::ggqqplot)
# skewness and kurtosis data via psych
## Not run:
info_df = peek_neat(
mtcars,
'wt',
group_by = 'cyl',
f_print = psych::describe,
f_plot = ""
)
info_df # contains all data returns by psych::describe
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.