Visualize data using ggplot2 https://ggplot2.tidyverse.org/
visualize(
dataset,
xvar,
yvar = "",
comby = FALSE,
combx = FALSE,
type = ifelse(is.empty(yvar), "dist", "scatter"),
nrobs = -1,
facet_row = ".",
facet_col = ".",
color = "none",
fill = "none",
size = "none",
fillcol = "blue",
linecol = "black",
pointcol = "black",
bins = 10,
smooth = 1,
fun = "mean",
check = "",
axes = "",
alpha = 0.5,
theme = "theme_gray",
base_size = 11,
base_family = "",
labs = list(),
xlim = NULL,
ylim = NULL,
data_filter = "",
arr = "",
rows = NULL,
shiny = FALSE,
custom = FALSE,
envir = parent.frame()
)Data to plot (data.frame or tibble)
One or more variables to display along the X-axis of the plot
Variable to display along the Y-axis of the plot (default = "none")
Combine yvars in plot (TRUE or FALSE, FALSE is the default)
Combine xvars in plot (TRUE or FALSE, FALSE is the default)
Type of plot to create. One of Distribution ('dist'), Density ('density'), Scatter ('scatter'), Surface ('surface'), Line ('line'), Bar ('bar'), or Box-plot ('box')
Number of data points to show in scatter plots (-1 for all)
Create vertically arranged subplots for each level of the selected factor variable
Create horizontally arranged subplots for each level of the selected factor variable
Adds color to a scatter plot to generate a 'heat map'. For a line plot one line is created for each group and each is assigned a different color
Display bar, distribution, and density plots by group, each with a different color. Also applied to surface plots to generate a 'heat map'
Numeric variable used to scale the size of scatter-plot points
Color used for bars, boxes, etc. when no color or fill variable is specified
Color for lines when no color variable is specified
Color for points when no color variable is specified
Number of bins used for a histogram (1 - 50)
Adjust the flexibility of the loess line for scatter plots
Set the summary measure for line and bar plots when the X-variable is a factor (default is "mean"). Also used to plot an error bar in a scatter plot when the X-variable is a factor. Options are "mean" and/or "median"
Add a regression line ("line"), a loess line ("loess"), or jitter ("jitter") to a scatter plot
Flip the axes in a plot ("flip") or apply a log transformation (base e) to the y-axis ("log_y") or the x-axis ("log_x")
Opacity for plot elements (0 to 1)
ggplot theme to use (e.g., "theme_gray" or "theme_classic")
Base font size to use (default = 11)
Base font family to use (e.g., "Times" or "Helvetica")
Labels to use for plots
Set limit for x-axis (e.g., c(0, 1))
Set limit for y-axis (e.g., c(0, 1))
Expression used to filter the dataset. This should be a string (e.g., "price > 10000")
Expression used to sort the data. Likely used in combination for `rows`
Rows to select from the specified dataset
Logical (TRUE, FALSE) to indicate if the function call originate inside a shiny app
Logical (TRUE, FALSE) to indicate if ggplot object (or list of ggplot objects) should be returned. This option can be used to customize plots (e.g., add a title, change x and y labels, etc.). See examples and https://ggplot2.tidyverse.org for options.
Environment to extract data from
Generated plots
See https://radiant-rstats.github.io/docs/data/visualize.html for an example in Radiant
visualize(diamonds, "price:cut", type = "dist", fillcol = "red")
visualize(diamonds, "carat:cut",
yvar = "price", type = "scatter",
pointcol = "blue", fun = c("mean", "median"), linecol = c("red", "green")
)
visualize(diamonds,
yvar = "price", xvar = c("cut", "clarity"),
type = "bar", fun = "median"
)
visualize(diamonds,
yvar = "price", xvar = c("cut", "clarity"),
type = "line", fun = "max"
)
visualize(diamonds,
yvar = "price", xvar = "carat", type = "scatter",
size = "table", custom = TRUE
) + scale_size(range = c(1, 10), guide = "none")
visualize(diamonds, yvar = "price", xvar = "carat", type = "scatter", custom = TRUE) +
labs(title = "A scatterplot", x = "price in $")
visualize(diamonds, xvar = "price:carat", custom = TRUE) %>%
wrap_plots(ncol = 2) + plot_annotation(title = "Histograms")
visualize(diamonds,
xvar = "cut", yvar = "price", type = "bar",
facet_row = "cut", fill = "cut"
)