library(repvisforODK)
library(readr)
library(knitr)
library(htmltools)
 knitr::opts_chunk$set(eval=TRUE, echo = FALSE, warning = FALSE, message = FALSE) 
# defining which code chunks to evaluate
all_plots <- c('donut', 'line_chart_cumsum', 'line_chart_no_cumsum', 'day_heatmap', 'cal_heatmap', 'single_pie', 'multiple_bar', 'wordcloud')
selected_plots <- c(params$plots_general, params$plots_question)

plot_evals <- lapply(all_plots, function(x) ifelse(x %in% selected_plots, TRUE, FALSE))
names(plot_evals) <- all_plots
# loading data
df <- repvisforODK::check_data_args(df = params$df)

# getting extended form schema when svc is used
df_schema_ext <- params$df_schema
# general
date_col <- params$date_col
daily_submission_goal <- as.numeric(params$daily_submission_goal)
svc <- params$svc

# for question-specific plots
label_col <- params$label_col
choice_col <- params$choice_col

# only for submissions_time series_lineplot
exclude_wday_str <- params$exclude_wday_str
exclude_wday_int <- match(exclude_wday_str, c('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'))

# only for multiple_choice_question_bar
delimiter <- params$delimiter

# only for word cloud
text_col <- params$text_col
text_col_name <- params$text_col_name
lang_wc <- params$lang_wc

Parameter Overview

SVC: r svc\ Date Column for Time Reference: r date_col\ Daily Submission Goal: r daily_submission_goal\ Label Column for Question Labels: r label_col\ Choice Column for Question Choices: r choice_col\ Excluded Days of the Week: r paste(exclude_wday_str, collapse = ', ')\ Delimiter Multiple Choice Questions: r paste0('"', delimiter, '"')\ Free Text Questions: r paste(text_col_name, collapse = ', ')\ Language of Free Text Question Answers: r lang_wc\


r if (!plot_evals$donut) {"\\begin{comment}"}

Number of Submissions: Received vs. Missing to Target

if (plot_evals$donut) {
  fig <- repvisforODK::submission_goal_donut(df = df, daily_submission_goal = daily_submission_goal, date_col = date_col, exclude_wday = exclude_wday_int)
} else fig <- NULL

fig

r if (!plot_evals$donut) {"\\end{comment}"}

r if (!plot_evals$line_chart_cumsum) {"\\begin{comment}"}

Received Submissions Over Time: Cumulative

if (plot_evals$line_chart_cumsum) {
  fig <- repvisforODK::submissions_timeseries_lineplot(df = df, daily_submission_goal = daily_submission_goal, date_col = date_col, exclude_wday = exclude_wday_int, cumulative = TRUE)
} else fig <- NULL

fig

r if (!plot_evals$line_chart_cumsum) {"\\end{comment}"}

r if (!plot_evals$line_chart_no_cumsum) {"\\begin{comment}"}

Received Submissions Over Time: Non-Cumulative

if (plot_evals$line_chart_no_cumsum) {
  fig <- repvisforODK::submissions_timeseries_lineplot(df = df, daily_submission_goal = daily_submission_goal, date_col = date_col, exclude_wday = exclude_wday_int, cumulative = FALSE)
} else fig <- NULL

fig

r if (!plot_evals$line_chart_no_cumsum) {"\\end{comment}"}

r if (!plot_evals$day_heatmap) {"\\begin{comment}"}

Submission Activitiy by Weekday and Day of the Week

if (plot_evals$day_heatmap) {
  fig <- repvisforODK::heatmap_wday_hourofday(df = df, date_col = date_col)
} else fig <- NULL

fig

r if (!plot_evals$day_heatmap) {"\\end{comment}"}

r if (!plot_evals$cal_heatmap) {"\\begin{comment}"}

Submission Activity by Day

if (plot_evals$cal_heatmap) {
  fig <- repvisforODK::heatmap_calendar(df = df, daily_submission_goal = daily_submission_goal, date_col = date_col)
} else fig <- NULL

fig

r if (!plot_evals$cal_heatmap) {"\\end{comment}"}

r if (!plot_evals$single_pie) {"\\begin{comment}"}

Distribution of Answers for Single-Choice Questions

if (plot_evals$single_pie) {
  plots <- repvisforODK::single_choice_question_pie(df = df, df_schema_ext = df_schema_ext, label_col = label_col, choice_col = choice_col)
} else plots <- NULL

if (length(plots) == 0) {
  print('No Single Choice Questions were identified.')
} else htmltools::tagList(plots)

r if (!plot_evals$single_pie) {"\\end{comment}"}

r if (!plot_evals$multiple_bar) {"\\begin{comment}"}

Distribution of Answers for Multiple-Choice Questions

if (plot_evals$multiple_bar) {
  plots <- repvisforODK::multiple_choice_question_bar(df = df, df_schema_ext = df_schema_ext, label_col = label_col, choice_col = choice_col)
} else plots <- NULL

if (length(plots) == 0) {
  print('No Multiple Choice Questions were identified.')
} else htmltools::tagList(plots)

r if (!plot_evals$multiple_bar) {"\\end{comment}"}

r if (!plot_evals$wordcloud) {"\\begin{comment}"}

Wordcloud for Free Text Question

if (plot_evals$wordcloud) {
  plots <- repvisforODK::free_text_wordcloud(df = df, text_col = text_col, lang_wc = lang_wc, df_schema_ext = df_schema_ext, label_col = label_col, choice_col = choice_col)
} else plots <- NULL

htmltools::tagList(lapply(plots, print)) 

r if (!plot_evals$wordcloud) {"\\end{comment}"}



lucidviews/repvisForODK documentation built on Feb. 13, 2022, 9:50 p.m.