-
-
Save vnijs/5df4f947f36f3a0b2ce5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# server.R | |
library("shiny") | |
shinyServer( | |
function(input, output, session) { | |
# Debug Area | |
output$Console <- renderUI({ | |
btnTags <- function(){tags$style(type = 'text/css',"")} | |
if (is.null(input$console) || !nzchar(input$console) || input$console == 0) { | |
btnTags <- function(){tags$style(type = 'text/css' | |
, '#console {color: rgb(221,17,68);}' | |
)} | |
} | |
list(btnTags(),actionButton(inputId = "console", label = "console")) | |
}) | |
observe(label = "console", { | |
if (is.null(input$console) || !nzchar(input$console)) {return()} | |
if (input$console != 0) { | |
options(browserNLdisabled = TRUE) | |
saved_console <- ".RDuetConsole" | |
if (file.exists(saved_console)) {load(saved_console)} | |
isolate(browser()) | |
save(file=saved_console,list=ls(environment())) | |
} | |
}) | |
} | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ui.R | |
library("shiny") | |
pageWithMultiPanels <- function(headerPanel,sidePanel,mainPanel,footerPanel) { | |
bootstrapPage(div(class = "container-fluid" | |
, div(class = "row-fluid", headerPanel) | |
, div(class = "row-fluid", sidePanel, mainPanel) | |
, div(class = "row-fluid", footerPanel) | |
) ) | |
} | |
footerPanel <- function(...) { | |
div(class="footer", hr(), ...) | |
} | |
shinyUI( | |
pageWithMultiPanels( | |
headerPanel = headerPanel(h5("Debug Panel - Demo")) | |
, | |
mainPanel = mainPanel( | |
helpText(h5("This is the app's main panel")) | |
, | |
helpText(a("Demo based on shiny-discuss message by Alex Brown", href="https://groups.google.com/forum/#!topic/shiny-discuss/YIusppqZ8cg", target="_blank")) | |
) | |
, | |
sidePanel = sidebarPanel( | |
helpText(h5("This is the app's side panel")) | |
, | |
helpText(a("Demo by Patrick Toche, 14 January 2014", href="https://gist.github.com/ptoche/8405209", target="_blank")) | |
) | |
, | |
footerPanel = footerPanel( | |
checkboxInput(inputId = "showDebug", label = "Debug?", value = FALSE) | |
, | |
conditionalPanel(condition = "input.showDebug == true" | |
, wellPanel( | |
h5("Debug Panel:") | |
, helpText(HTML("Click to run code in the console")) | |
, uiOutput("Console"), br() | |
, helpText(HTML("The console should display a Browse prompt: <code>Browse[1]></code>")) | |
, helpText(HTML("Enter <code>c</code> at the prompt to stop communication with the console and resume with the shiny app")) | |
) | |
) | |
) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment