% Generated by roxygen2: do not edit by hand % Please edit documentation in R/data_plots.R, R/plot-helpers.R, R/plot_bar.R, % R/plot_box.R, R/plot_hbar.R, R/plot_likert.R, R/plot_ridge.R, % R/plot_sankey.R, R/plot_scatter.R, R/plot_violin.R \name{data-plots} \alias{data-plots} \alias{data_visuals_ui} \alias{data_visuals_server} \alias{create_plot} \alias{plot_bar} \alias{plot_bar_single} \alias{plot_box} \alias{plot_box_single} \alias{plot_hbars} \alias{plot_likert} \alias{plot_ridge} \alias{sankey_ready} \alias{plot_sankey} \alias{plot_scatter} \alias{plot_violin} \title{Data correlations evaluation module} \usage{ data_visuals_ui(id, tab_title = "Plots", ...) data_visuals_server(id, data, palettes = color_choices(), ...) create_plot(data, type, pri, sec, ter = NULL, color.palette = "viridis", ...) plot_bar( data, pri, sec = NULL, ter = NULL, style = c("stack", "dodge", "fill"), color.palette = "viridis", max_level = 30, ... ) plot_bar_single( data, pri, sec = NULL, style = c("stack", "dodge", "fill"), max_level = 30, color.palette = "viridis" ) plot_box(data, pri, sec, ter = NULL, color.palette = "viridis", ...) plot_box_single(data, pri, sec = NULL, seed = 2103, color.palette = "viridis") plot_hbars(data, pri, sec, ter = NULL, color.palette = "viridis", ...) plot_likert(data, pri, sec = NULL, ter = NULL, color.palette = "viridis", ...) plot_ridge(data, x, y, z = NULL, color.palette = "viridis", ...) sankey_ready(data, pri, sec, numbers = "count", ...) plot_sankey( data, pri, sec, ter = NULL, color.group = "pri", colors = NULL, color.palette = "viridis", default.color = "#2986cc", box.color = "#1E4B66", na.color = "grey80", missing.level = "Missing", ... ) plot_scatter(data, pri, sec, ter = NULL, color.palette = "viridis", ...) plot_violin(data, pri, sec, ter = NULL, color.palette = "viridis", ...) } \arguments{ \item{id}{Module id. (Use 'ns("id")')} \item{...}{passed on to wrap_plot_list} \item{data}{data frame} \item{type}{plot type (derived from possible_plots() and matches custom function)} \item{pri}{primary variable} \item{sec}{secondary variable} \item{ter}{tertiary variable} \item{color.palette}{choose color palette. See \code{\link{plot_colors}} for support.} \item{style}{barplot style passed to geom_bar position argument. One of c("stack", "dodge", "fill")} } \value{ Shiny ui module shiny server module ggplot2 object ggplot list object ggplot object ggplot2 object ggplot object ggplot2 object ggplot2 object ggplot2 object data.frame ggplot2 object ggplot2 object ggplot2 object } \description{ Data correlations evaluation module Wrapper to create plot based on provided type Title Single vertical barplot Beautiful box plot(s) Create nice box-plots Nice horizontal stacked bars (Grotta bars) Nice horizontal bar plot centred on the central category Plot nice ridge plot Readying data for sankey plot Beautiful sankey plot with option to split by a tertiary group Beautiful violin plot Beautiful violin plot } \examples{ create_plot(mtcars, "plot_violin", "mpg", "cyl") |> attributes() mtcars |> dplyr::mutate(cyl = factor(cyl), am = factor(am)) |> plot_bar(pri = "cyl", sec = "am", style = "fill") mtcars |> dplyr::mutate(dplyr::across(tidyselect::all_of(c("cyl","am","gear")),factor)) |> plot_bar(pri = "cyl", sec = "gear", ter = "am", style = "stack",color.palette="turbo") mtcars |> dplyr::mutate(cyl = factor(cyl), am = factor(am)) |> plot_bar_single(pri = "cyl", sec = "am", style = "fill") mtcars |> dplyr::mutate(cyl = factor(cyl), am = factor(am)) |> plot_bar_single(pri = "cyl", style = "stack",color.palette="turbo") mtcars |> plot_box(pri = "mpg", sec = "gear") mtcars |> plot_box(pri = "mpg", sec="cyl") mtcars |> default_parsing() |> plot_box(pri = "mpg", sec = "cyl", ter = "gear") mtcars |> default_parsing() |> plot_box(pri = "mpg", sec = "cyl", ter = "gear",axis.font.family="mono") mtcars |> plot_box_single("mpg") mtcars |> plot_box_single("mpg","cyl",color.palette="Blues") stRoke::trial |> plot_box_single("age","active",color.palette="Blues") gtsummary::trial |> plot_box_single("age","trt") mtcars |> plot_hbars(pri = "carb", sec = "cyl") mtcars |> plot_hbars(pri = "carb", sec = "cyl", ter="am") mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Blues") mtcars |> plot_hbars(pri = "carb", sec = NULL,color.palette="Magma") mtcars |> plot_hbars(pri = "carb", sec = "am",color.palette="Viridis") mtcars |> plot_likert(pri = "carb", sec = "cyl") mtcars |> plot_likert(pri = "carb", sec = "cyl", ter="am") mtcars |> plot_likert(pri = "cyl",color.palette="Blues") mtcars |> plot_likert(pri = "carb", sec = NULL,color.palette="Magma") mtcars |> plot_likert(pri = "carb", sec = c("cyl","am"),color.palette="Viridis") mtcars |> default_parsing() |> plot_ridge(x = "mpg", y = "cyl") mtcars |> plot_ridge(x = "mpg", y = "cyl", z = "gear") ds <- data.frame(g = sample(LETTERS[1:2], 100, TRUE), first = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE)), last = sample(c(letters[1:4], NA), 100, TRUE, prob = c(rep(.23, 4), .08))) ds |> sankey_ready("first", "last") ds |> sankey_ready("first", "last", numbers = "percentage") data.frame( g = sample(LETTERS[1:2], 100, TRUE), first = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE)), last = sample(c(TRUE, FALSE, FALSE), 100, TRUE) ) |> sankey_ready("first", "last") ds <- data.frame(g = sample(LETTERS[1:2], 100, TRUE), first = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE)), last = REDCapCAST::as_factor(sample(letters[1:4], 100, TRUE))) ds |> plot_sankey("first", "last") ds |> plot_sankey("first", "last", color.group = "sec") ds |> plot_sankey("first", "last", ter = "g", color.group = "sec") mtcars |> default_parsing() |> plot_sankey("cyl", "gear", "am", color.group = "pri") ## In this case, the last plot as the secondary variable in wrong order ## Dont know why... mtcars |> default_parsing() |> plot_sankey("cyl", "gear", "vs", color.group = "pri",color.palette="inferno") mtcars |> plot_scatter(pri = "mpg", sec = "wt") mtcars |> plot_scatter(pri = "mpg", sec = "wt",ter="carb") mtcars |> plot_violin(pri = "mpg", sec = "cyl") mtcars |> plot_violin(pri = "mpg", sec = "cyl", ter = "gear", color.palette="Blues") }