Automatically generating a deck for every variable (using R)
Researchers may like to kick-start their analysis by having a ready-made deck, with one slide per variable in the dataset. For each variable type, there is a graph or table set up as the default.
At this stage, R code can be run to generate such a Deck.
The following assumes you have already logged in and loaded a dataset.
library(crunch)
login()
ds <- loadDataset()
vars <- as.data.frame(variables(ds))
newDeck(ds, "Auto Report")
deck <- decks(ds)[[1]]
for (i in 1:nrow(vars)) {
if (vars[i, "type"] == "categorical_array") {my_viz <- "horizontalBarPlot"}
if (vars[i, "type"] == "categorical") {my_viz <- "donut"}
if (vars[i, "type"] == "date") {my_viz <- "table"}
newSlide(deck,
query = as.formula(paste0("~ ", vars[i,"alias"])),
title = vars[i,"name"],
subtitle = "",
display_settings = list(vizType = my_viz)
)
}
Further info
Technical documentation - see the Crunch R reference