Sunday 15 April 2012

r - Objects aren't recognized unless manually created -



r - Objects aren't recognized unless manually created -

my server.r file begins:

library(shiny) source("scripts/0-prepare-inputs.r") source("scripts/1-analysis-functions.r") shinyserver(function(input, output) {})

if manually execute 2 helper scripts, runapp() works desired. however, if start clearing environment , allowing source() commands run scripts, 2 objects created in 0-prepare-inputs.r aren't found. error appears such:

> shiny::runapp() listening on http://127.0.0.1:5591 error in lapply(obj, function(val) { : object 'stabletypes' not found

stabletypes generated in next manner within 0-prepare-inputs.r:

stabletypes <- list(races = c("all", "white", "black", "hispanic", "nhwhite", "nhblack"), genders = c("total", "male", "female"))

running line allows runapp() function properly.

i need solve problem in order create utilize of shinyapps.io.

things i've tried don't work:

changing local parameter in source(). replacing source() command lines of source files. wrapping creation of stabletypes in function called in script file. wrapping creation of stabletypes in function called reactive object. saving stabletypes robject , loading in source scripts , @ top of server.r. saving stabletypes using super-assignment. saving stabletypes using assign() , specifying envir = .globalenv. running scripts, saving environment using save.image() , loading environment using load(..., envir = .globalenv)

all packages date per update.packages(), , i'm running r version 3.1.1.

based on comment suggestion source file in global.r. can create file in same directory ui.r , server.r files. in file avialable both ui , server.

r shiny

No comments:

Post a Comment