Implement R-Files from subfolders into Shiny -


i want stick kiss (keep simple, stupid) principle within shiny app (http://code.tutsplus.com/tutorials/3-key-software-principles-you-must-understand--net-25161).

so created folder , subfolders , saved peaces of code uses in server.r functions , .r files. here 2 examples of 2 saved .r files:

output$mychoices <- renderui({     selectinput(inputid = 'x',                  label = 'y',                  choices = levels(mydataset$df$z),                 multiple = t     ) }) 

or

absolutematrix <- reactive({     lifechar <- switch(as.integer(input$something),                    "abc",                    "def",                    "ghi",                    "jkl",                    "mno"      )       if( (myboolean$absolute == true) && (length(input$xy) != 0) ){          if( (length(input$gh) == 0) ) {             return(mydata()[,grepl(lifechar, names(mydata()))] %>%                         na.omit %>%                         as.matrix)          } else if( (length(input$gh) != 0) ) {             return(mydatax()[,grepl(lifechar, names(mydatax()))] %>%                         na.omit %>%                         as.matrix)         }      } }) 

in server.r wrote following

library(shiny) source("onload.r")    shinyserver(function(input, output, session) {       sourcerecursive("/.../")   }) 

in onload.r file function sourcerecursive defined:

 #check folder , subfolders .r files  #source() them!   sourcerecursive <- function(path) {       dirs <- list.dirs()       files <- dir(pattern = "^.*[rr]$", include.dirs = false)       (f in files)           source(f)       (d in dirs)           sourcerecursive(d)    } 

but, did not trick. seems not load files or there might problems reactivity of content.

add 'local = true' source() function.


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -