r - Shiny - Why does Shiny not react to the result of an evaluated/parsed expression? -


please refer this question of functions , context.

here's overview of app. some of console output , debugging output shown here.

the code

right now, i'm trying "cure" server code:

env = module_env$normalization  eval(envir= module_env$normalization, {  jjjj <- reactive({   eval(parse(text=paste(sep='', "input$", mod_id('var_echo')))) })  #### #### vvvvvvvvvvvvvvvvvvvv #### observeevent(jjjj, { # observeevent(evalq(parse(text=paste(sep='', 'input$', mod_id('var_echo', env)))), {   print("hey")   print(get('sum_exp', env)) }) #### #### ^^^^^^^^^^^^^^^^^^^^^^ ####  observeevent(input$print_mod_id, {   browser()    print(mod_id('var_echo', env))   print(paste("input$", mod_id('var_echo', env), sep=''))   print(parse(text=paste(sep='', "input$", mod_id('var_echo', env))))   print(eval(parse(text=paste(sep='', "input$", mod_id('var_echo', env))))) })  }) 

which meant paired ui code:

module_env$normalization <- new.env() env = module_env$normalization  evalq(envir = env, {   #create ui here   ui_normalization <-   tabsetpanel(     tabpanel('normalization (fpkm)',       p("normalization"),       actionbutton(inputid = mod_id('var_echo', env), "echo variables"),       actionbutton("print_mod_id", "print module ui")     )   )    print(mod_id('var_echo', env))    #create initial input/output variables here   sum_exp <- null   output_sum_exp <- null    #always register last   register_module(     name="normalization (fpkm)",     module=ui_normalization,     env=env,     inputs=c('sum_exp'),     outputs=c('output_sum_exp')   ) }) 

these 2 files called @ separate times during app, ultimately, called using source("filename.r", local=true) localize environment of source file global environment, holds app.


the problem

most of debugging, important thing expression jjjj being read shiny (the app run), doesn't react when button pressed.

mod_id() special function designed react environment called generate special key based on string , calling environment:

###sample results print_mod_id print statements  [1] "id0x000000001e9047f0__var_echo" [1] "input$id0x000000001e9047f0__var_echo" expression(input$id0x000000001e9047f0__var_echo) [1] 2 attr(,"class") [1] "integer"                "shinyactionbuttonvalue" 

here's mod_id(string, environment), returns string:

mod_id <- function(name, envir = null) {   if(identical(envir, globalenv())) {     e = envir   } else if (is.null(envir)) {     e = parent.frame()   } else if (is.environment(envir)) {     e = envir   } else {     stop("given non-default argument \'envir\' not environment")   }   return(paste(sep = "",     "id",     sub('<environment: (.*)>', '\\1', capture.output(e)),     "__",     name     )   ) } 

testing observations

here's of tests i've done:

  1. the unique ids generated mod_id() ui , server indeed same. i've gone in , fixed discrepancies, match up.
  2. the expression used final input$input_id_for_shiny name works in case, except when variable name substituted function mod_id(). i'm not sure why, might have evaluation order caused overarching eval statement.
  3. the event triggered jjjj triggered once @ beginning of app. have no idea why happens, fact does.

edit: additional testing, have shiny source code on machine. expression now: evalq(as.name(paste(sep='', 'input$', mod_id('var_echo', env)))) still doesn't work.


Comments