qplot_walk {mctq} | R Documentation |
Walk through distribution plots
Description
This function will be removed on the next mctq
version. You can still find
it in the gutils
package.
qplot_walk()
helps you to visually assess the distribution of your data. It
uses geom_bar()
(for non double
variables) or geom_histogram()
(for
double
variables) to walk through each selected variable
from a data frame.
Usage
qplot_walk(
data,
...,
cols = NULL,
pattern = NULL,
ignore = "character",
remove_id = TRUE,
midday_change = TRUE
)
Arguments
data |
An |
... |
(optional) additional arguments to be passed to
|
cols |
(optional) (only for data frames) a
|
pattern |
(optional) (only for data frames) a string with a regular
expression to select column names in |
ignore |
(optional) (only for data frames) a
|
remove_id |
(optional) (only for data frames) a
|
midday_change |
(optional) a |
Details
Requirements
This function requires the ggplot2
,
grDevices
, and
utils
packages and can only run in
interactive mode. The utils
and
grDevices
packages comes with a standard R
installation and is typically loaded by default. Most people also run R
interactively.
If you don't have any or one of the packages mentioned above, you can install
them with install.packages("ggplot2", "grDevices", "utils")
.
Plot recover
qplot_walk()
clears all plots after it runs. For that reason, the function
first emits a dialog message warning the user of this behavior before it
runs. If you want to recover a single distribution plot, assign the variable
vector to the data
argument.
Additional arguments to geom_bar()
or geom_histogram()
qplot_walk()
uses ggplot2
geom_bar()
(for non double
variables) or geom_histogram()
(for
double
variables) to generate plots. If you are familiar
with these functions, you can pass additional arguments to the them using
the ellipsis argument (...
).
Note that x
, y
, and data
arguments are reserved for qplot_walk()
.
Duration
, Period
, and difftime
objects
To help with the visualization, qplot_walk()
automatically converts
Duration
, Period
, and
difftime
objects to hms
.
Midday change
Time variables with values greater than 22:00:00
will automatically be
converted to POSIXct' and be attached to a two-day
timeline using the midday hour as a cutting point, i.e., all values with 12
hours or more will be placed on day 1, and all the rest will be placed on day
2.
This is made to better represent time vectors that cross the midnight hour.
You can disable this behavior by using midday_change = FALSE
.
Example: Say you have a vector of time values that cross the midnight hour
(e.g., an hms
vector with 22:00
, 23:00
, 00:00
, 01:00
values). If you use midday_change = FALSE
, your data will be represented
linearly.
00:00 01:00 22:00 23:00 |-----|------------------------------------|-----|------->
By using midday_change = TRUE
(default), qplot_walk()
will fit your data
to a circular time frame of 24 hours.
day 1 day 2 22:00 23:00 00:00 01:00 ------------------|-----|-----|-----|---------------------->
id
variables
qplot_walk()
will ignore any variable with the follow name pattern
"^id$|[\\._-]id$"
, i.e., any variable named id
or that ends with
.id
, _id
, or -id
.
You can disable this behavior using remove_id = FALSE
.
Value
An invisible NULL
. This function don't aim to return values.
Examples
if (interactive()) {
## Ploting a single column from 'data'
qplot_walk(mctq::std_mctq$bt_w)
## Ploting all columns from 'data'
qplot_walk(mctq::std_mctq)
## Ploting selected columns from 'data'
qplot_walk(mctq::std_mctq, cols = c("bt_w", "msf_sc"))
## Ploting selected columns from 'data' using a name pattern
qplot_walk(mctq::std_mctq, pattern = "_w$")
## Examples using other datasets
if (requireNamespace("datasets", quietly = TRUE)) {
qplot_walk(datasets::iris)
}
}