| tinyplot.data.frame | R Documentation |
Convenience interface for visualizing
data.frame objects with tinyplot.
## S3 method for class 'data.frame'
tinyplot(x, formula = NULL, by = NULL, labs = FALSE, frames = FALSE, ...)
tinypairs(x, by = NULL, labs = FALSE, frames = FALSE, ...)
x |
an object of class |
formula |
a |
by |
(pairs-case only) optional grouping variable. Either 1) a character
string giving a column name in |
labs |
(pairs-case only) logical indicating whether the axes labels
(titles) for each sub-plot in the pairs-style case should be shown. Default
is |
frames |
(pairs-case only) logical indicating whether each sub-plot should
be framed by a box. Default is |
... |
further arguments passed to |
This is a convenience function for plotting data frames with
or without a formula. The case with the formula mainly facilitates
using tinyplot() in combination with pipes. The case without
formula provides a quick way of plotting the variables in a data frame:
a single variable, a pair of variables, or a
pairs-style grid of all variable combinations for
3 or more variables. The latter can be called directly (also for less than
3 variables) via tinypairs().
Note that, unlike a base pairs plot, these
tinyplot variants (deliberately) produce a histogram for the univariate
cases along the grid diagonal.
By default, no return value; called for the side effect of producing
a plot. If record = TRUE (or globally via tpar(record = TRUE)), the
plot is instead returned invisibly as a "recordedtinyplot" object; see
recordedtinyplot. The exception is the pairs-style case
(more than two columns), which draws a grid of sub-plots and always
returns NULL.
## using tinyplot() with data frames
tinyplot(cars)
tinyplot(iris, Sepal.Length ~ Petal.Width | Species)
tinyplot(
as.data.frame(UCBAdmissions),
Admit ~ Gender, facet = 1 ~ Dept, weights = Freq
)
## note that this also enables usage with pipes (in R >= 4.1.0) such as
# cars |> tinyplot()
# iris |> tinyplot(Sepal.Length ~ Petal.Width | Species)
# UCBAdmissions |>
# as.data.frame() |>
# tinyplot(Admit ~ Gender, facet = 1 ~ Dept, weights = Freq)
# etc.
## pairs-style display for data frames with 3 or more variables
## (works best with a theme)
tinytheme("clean2")
tinyplot(iris)
## pass `by` arg to group the pairs display (legend is suppressed)
## here, we also add optional frames around the individual sub-plots
tinyplot(iris, by = "Species", frames = TRUE)
## another option (but assumes objects of equal length)
tinyplot(iris[, 1:4], by = iris$Species, frames = TRUE)
## tinypairs can also create 2x2 pairs display
tinypairs(iris[, c(3, 1)], by = iris$Species)
tinytheme() ## reset theme
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.