UIOutput level plot test

  library(shinyWidgets) #draw_data <- readRDS(“/home/sixx/d2cm/1.RCodes/4.Etc/9.sixx/draw_data.rds”) init_env0 <- function(){ env <- new.env() env$dd <- NULL return(env) } env6 <- init_env0() server <- function(input,output, session){ uFunc_draw_plot<- function(dd, selected_col, val_limit){ p <- dd %>% ggplot(aes_string(x=”sec”, y=”val”, group=”subid”, color=selected_col)) + coord_cartesian(ylim=val_limit) + geom_point() + geom_line() output$O_plt_main <- renderPlot({ return(p) }) } observeEvent(input$I_btn_load_make_dd, { if Read more…

shinyWidget :: radioGroupButtons

  library(shinyWidgets) server <- function(input, output, session) { output$val <- renderText({ input$rdoG_letter }) } ui <- fluidPage( fluidRow( column(width=3, radioGroupButtons(“rdoG_letter”, label=”Choose one:”, choices=list(“A”=1,”B”=2,”C”=3), selected=3, width=”100%” #individual = T, direction = “vertical”, status = “danger” )), column(width=9, verbatimTextOutput(“val”)) ) ) shinyApp(ui, server) radioGroupButtons(inputId, label = NULL, choices = NULL, selected = Read more…

shinyTime

https://cran.r-project.org/web/packages/shinyTime/index.html server = function(input, output,session) { } ui <- fluidPage( # Default value is 00:00:00 timeInput(“time1”, “Time:”), # Set to current time timeInput(“time2”, “Time:”, value = Sys.time()), # Set to custom time timeInput(“time3”, “Time:”, value = strptime(“12:34:56”, “%T”)), # Use %H:%M format timeInput(“time4”, “Time:”, seconds = FALSE) ) shinyApp(ui, server) Read more…

Slider Input Widget

https://shiny.rstudio.com/articles/sliders.html https://stackoverflow.com/questions/36906265/how-to-color-sliderbar-sliderinput #runExample(“05_sliders”) server <- function(input, output, session){} ui <- fluidPage( titlePanel(“Sliders!”), sidebarLayout( sidebarPanel( # Single Value —- sliderInput(“integer”, “Integer”, min=0, max=1000, value=500, step=10), # Range sliderInput(“range”, “Range:”, min=1, max=1000, value=c(200,500), step=1), # CSS from .js-irs-0 —- tags$style(HTML(“.js-irs-2 .irs-single, .js-irs-2 .irs-bar-edge, .js-irs-2 .irs-bar { background: red } “)), sliderInput(“slider1”, “Red”, Read more…

Validate

https://shiny.rstudio.com/articles/validation.html https://groups.google.com/forum/#!topic/shiny-discuss/A-eG6Birr0s 주의사항 “is.character(txt) is not TRUE”  jsonlite::validate(txt =)은 한개의 text string을 argument로 받고 shiny::validate(조건, “error message”)은  다르다. 로딩순서 중요! (먼저 로딩된 package의 function은 masking 되기 때문에) library(jsonlite) library(shiny)     에러메세지는 User가 알아보기 힘든 경우가 많다.  validate( need(input$data != “”, “Please select a data set”), errorClass = “myClass” ) Read more…

shinyboard :: dropdown notifications menu

library(shiny) library(shinyjs) library(shinydashboard) header <- dashboardHeader(dropdownMenuOutput(“taskMenu”)) sidebar <- dashboardSidebar() body <- dashboardBody(useShinyjs()) ui <- dashboardPage(header, sidebar, body) server <- function(input, output, session) { uFunc_memory_info <- function(){ mem <- system(“free -g”, intern=T) mem <- str_split(mem, pattern = “\\s{2,}” ) mem_all <- as.numeric(mem[[2]][2]) mem_use <- as.numeric(mem[[2]][3]) swap_all <- as.numeric(mem[[3]][2]) swap_use <- as.numeric(mem[[3]][3]) Read more…

reactiveValue example

    https://stackoverflow.com/questions/37634614/how-to-call-a-function-once-and-then-use-the-results-multiple-times library(shiny) ui <- fluidPage( sidebarLayout( sidebarPanel( actionButton(“action”, “RUN”) ), mainPanel( textOutput(“text1”), textOutput(“text2”) ) ) ) server <- function(input, output) { values <- reactiveValues() function_to_get_list <- function(){ return(list(c(1:5))) } values[[‘1’]] <- function_to_get_list() output$text1 <- renderText({ if(input$action > 0) paste(“1st element of list “, values[[‘1’]][[1]][[1]]) }) output$text2 <- renderText({ Read more…

eventReactive example

  https://shiny.rstudio.com/images/shiny-cheatsheet.pdf library(shiny) ui <- fluidPage( textInput(“x”,”input Text:”,””), actionButton(“go”, “Proceed”), textOutput(“result”) ) server <- function(input,output){ re <- eventReactive(input$go, { input$x }) output$result <- renderText({ re() }) } shinyApp(ui, server)   library(shiny) ui <- fluidPage( column(4, numericInput(“x”, “Value”, 5), br(), actionButton(“button”, “Show”) ), column(8, tableOutput(“table”)) ) server <- function(input,output){ # Take Read more…

conditional panel

    https://shiny.rstudio.com/reference/shiny/1.0.1/conditionalPanel.html ConditionalPanel     https://stackoverflow.com/questions/39405136/how-to-use-actionbutton-as-a-trigger-to-conditionalpanel?rq=1 conditionalPanel works on client side(js), so its not see your variable. Here you can do it on server side using renderUI   library(shinyjs) ui <- fluidPage( useShinyjs(), actionButton(“Button_Initial”, “Button_Initial”) ) #*————————————————————————- ==== server <- function(input, output, session) { init_env1 <- function(){ env <- new.env() Read more…

rhandsontable formatting renderer

https://jrowen.github.io/rhandsontable/#formatting https://stackoverflow.com/questions/44813590/rhandsontable-conditional-formatting-how-to-highlight-rows-based-on-specific-at https://cran.r-project.org/web/packages/shinyjs/vignettes/shinyjs-extend.html http://onesixx.com/ggplot-ggplot_build/ groupOfColor <- ggplot_build(p)$data[[1]][, 1] %>% unique http://onesixx.com/rhandsontable-2/ ### DATA —- MAT = matrix(runif(9, -1, 1), nrow = 3, dimnames = list(LETTERS[1:3], LETTERS[1:3])) diag(MAT) = 1 MAT[upper.tri(MAT)] = MAT[lower.tri(MAT)] DF <- data.frame(MAT) ### Color —- groupOfColor <- c(“#F8766D”, “#00BA38”, “#619CFF”) ### Make Javascript —- jsColor_Header <- “function(instance, Read more…

ShinySky

https://github.com/AnalytixWare/ShinySky Handsontable Input/Output https://code.i-harness.com/en/q/1d4f505 #rm(list = ls()) library(shiny) library(shinysky) ui <- basicPage( mainPanel( column(6, hotable(“hotable1”)), column(6, DT::dataTableOutput(‘tbl’)) ) ) server <- function(input, output, session){ # Initiate your table previous <- reactive({head(mtcars)}) Trigger_orders <- reactive({ if(is.null(input$hotable1)){ return(previous()) }else if(!identical(previous(), input$hotable1)){ # hot.to.df function will convert your updated table into the dataframe Read more…

textOutput vs. verbatimTextOutput

  둘다 renderText({  }) 를 input으로 받아서,  textOutput은   기본적으로 <div>  이고,  인라인일때는 <span>   이 자동적으로 적용되며, Container 로 <pre>  H1  H2 등으로   변경하여 적용할수 있다.  textOutput(outputId, container=if (inline) span else div, inline=F)   verbatimTextOutput 은 <pre>        verbatimTextOutput(outputId, placeholder=F) output문자들에 박스가 기본적으로 적용되며, placeholder여부에 따라 처음부터 빈 박스를 안보여줄수 있다.  Read more…

rhandson Get selected rows of Rhandsontable

   selectCallback=TRUE을 사용 library(shiny) library(rhandsontable) library(data.table) init_env4 <- function(){ env <- new.env() env$select_idx <- NULL return(env) } env4 <- init_env4() ui = fluidPage( # rHandsonTable Grid rHandsontableOutput(‘rht_table’), br(), # Display result verbatimTextOutput(‘resultDisplay1’), verbatimTextOutput(‘resultDisplay2’), verbatimTextOutput(‘resultDisplay3’) ) server <- function(input, output, session) { # Data for grid baseData <- data.table(AA=c(1:10), BB=TRUE, CC=LETTERS[1:10], Read more…

press Button “enter” key action in shiny Math.random()

    tags$head(tags$script(HTML( “$(document).keyup(function(event) { if (event.keyCode == 13) { $(‘#logInsignin’).click(); } });” ))),       #tags$head(tags$script(src = “../../www/AAA.js”)), tags$head(tags$script(HTML( “$(document).keyup(function(event) { if ($(‘#BB’).is(‘:focus’) && (event.keyCode == 13)) { $(‘#CC’).click(); } });” ))),         # tags$head(tags$script(src = “enter_button.js”)), tags$head(tags$script(HTML( “$(document).keyup(function(event) { if ($(‘#logInpassword’).is(‘:focus’) && (event.keyCode == Read more…

diagModal

https://shiny.rstudio.com/reference/shiny/latest/modalDialog.html https://shiny.rstudio.com/reference/shiny/latest/showModal.html https://shiny.rstudio.com/reference/shiny/latest/showNotification.html ui <- fluidPage( actionButton(“btn_popupEnable”, “Show Popup”), verbatimTextOutput(“text_dataInfo”) ) server <- function(input, output, session) { storeDataset <- reactiveValues(resultData=NULL) popupModalUI <- function(failed=FALSE){ modalDialog( textInput(“myDataset”, “Choose data set”, placeholder=’Enter dataset…’), span(“(Try ‘mtcars’, “, “like ‘abc’)”), if(failed) div(tags$b(“Invalid name of Data”, style=”color:red;”)), footer=tagList( actionButton(“popup_ok”, “OK”), actionButton(“popup_cancel”, “Cancel”) # modalButton(“Cancel”) ) ) Read more…