if (FALSE) {
# Bar plots with single and dual colors
dat <- data.frame(
Metric = c("Sales", "Conversion", "Growth", "Efficiency"),
Value = c(75, 45, 92, 38),
Percentage = c(0.75, 0.45, 0.92, 0.38)
)
tt(dat) |>
plot_tt(j = 2, fun = "bar", data = as.list(dat$Value), color = "darkorange") |>
plot_tt(j = 3, fun = "bar", data = as.list(dat$Percentage),
color = c("steelblue", "lightgrey"), xlim = c(0, 1))
# Built-in plot types
plot_data <- list(mtcars$mpg, mtcars$hp, mtcars$qsec)
dat <- data.frame(
Variables = c("mpg", "hp", "qsec"),
Histogram = "",
Density = "",
Line = ""
)
# Random data for sparklines
lines <- lapply(1:3, \(x) data.frame(x = 1:10, y = rnorm(10)))
tt(dat) |>
plot_tt(j = 2, fun = "histogram", data = plot_data) |>
plot_tt(j = 3, fun = "density", data = plot_data, color = "darkgreen") |>
plot_tt(j = 4, fun = "line", data = lines, color = "blue") |>
style_tt(j = 2:4, align = "c")
# Custom function example (must have ... argument)
custom_hist <- function(d, ...) {
function() hist(d, axes = FALSE, ann = FALSE, col = "lightblue")
}
tt(data.frame(Variables = "mpg", Histogram = "")) |>
plot_tt(j = 2, fun = custom_hist, data = list(mtcars$mpg))
}
Run the code above in your browser using DataLab