From a6f774ee6f8e6f0fb9faed1039c297691c82ce2d Mon Sep 17 00:00:00 2001 From: Javier Matias Date: Thu, 26 Nov 2020 17:34:11 -0500 Subject: [PATCH] Added an option to specify the theme of the interactive explainer. --- R/shiny.R | 7 ++++--- man/interactive_text_explanations.Rd | 12 +++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/R/shiny.R b/R/shiny.R index cd75c60..75c56e9 100644 --- a/R/shiny.R +++ b/R/shiny.R @@ -9,7 +9,7 @@ #' @param window_title,title,place_holder,minimum_lentgh_error text to be displayed on the page #' @param minimum_lentgh don't update display if text is shorter than this parameter #' @param max_feature_to_select up limit to the number of words that can be selected -#' +#' @param shinytheme default is 'superhero'. #' @rdname interactive_text_explanations #' @importFrom shiny fluidPage textAreaInput shinyApp sliderInput mainPanel titlePanel hr need validate h1 h2 h3 h4 h5 h6 numericInput selectInput sidebarPanel renderPlot plotOutput #' @importFrom stringi stri_count_words stri_replace_all_fixed @@ -49,7 +49,8 @@ interactive_text_explanations <- function(explainer, window_title = "Text model place_holder = "Put here the text to explain", minimum_lentgh = 3, minimum_lentgh_error = "Text provided is too short to be explained (>= 3).", - max_feature_to_select = 20) { + max_feature_to_select = 20, + shinytheme = 'superhero') { assert_that(is.list(explainer)) assert_that(is.string(window_title)) assert_that(is.string(title)) @@ -67,7 +68,7 @@ interactive_text_explanations <- function(explainer, window_title = "Text model }) ui <- fluidPage(title = window_title, - theme = shinytheme("superhero"), + theme = shinytheme(shinytheme), titlePanel(title = title), hr(), sidebarPanel( diff --git a/man/interactive_text_explanations.Rd b/man/interactive_text_explanations.Rd index 75a9d49..907b2e9 100644 --- a/man/interactive_text_explanations.Rd +++ b/man/interactive_text_explanations.Rd @@ -6,12 +6,16 @@ \alias{render_text_explanations} \title{Interactive explanations} \usage{ -interactive_text_explanations(explainer, +interactive_text_explanations( + explainer, window_title = "Text model explainer", title = "Local Interpretable Model-agnostic Explanations", - place_holder = "Put here the text to explain", minimum_lentgh = 3, + place_holder = "Put here the text to explain", + minimum_lentgh = 3, minimum_lentgh_error = "Text provided is too short to be explained (>= 3).", - max_feature_to_select = 20) + max_feature_to_select = 20, + shinytheme = "superhero" +) text_explanations_output(outputId, width = "100\%", height = "400px") @@ -26,6 +30,8 @@ render_text_explanations(expr, env = parent.frame(), quoted = FALSE) \item{max_feature_to_select}{up limit to the number of words that can be selected} +\item{shinytheme}{default is 'superhero'.} + \item{outputId}{output variable to read from} \item{width, height}{Must be a valid CSS unit or a number, which will be coerced to a string and have "px" appended.}