R闪亮的环境

斯里

我对Shiny应用程序中的环境作用域感到困惑。我读到,在shinyServer函数外部定义的任何对象server.R都可用于所有用户会话。但是,如果我使用assign功能和envir=.GlobalEnv选项创建对象,那么该对象可用于其他用户会话吗?

我想在shinyServer函数内创建一些对象,并在用户单击之间保留它们,但不与其他用户会话共享它们-我该如何实现?

R全局用户环境是否是ShinyUser会话的父环境,而该环境是在ShinyServer函数中创建所有对象的环境的父环境?

感谢您在澄清此问题上的任何帮助。

谢谢

下面,我举了一个示例,该示例在与闪亮的不同环境相对应的位置处带有注释。实际上,这非常简单。

另请参阅RStudio核心团队提供的备忘单:

http://shiny.rstudio.com/articles/cheatsheet.html

# This will only run once when the app is launched.
# Load libraries, data or other objects that should be
# available globally for all users/sessions.

shinyServer(function(input, output) {

  # User/session specific objects go here.
  # This will be run each time a user visits the app or 
  # reloads the browser.

  output$text <- renderText ({

    input$myInput

    # This is a reactive object so this code will
    # be run everytime the parameter myInput is changed.
    # The objects inside the render element or not available
    # outside of the function.

    })
 })

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章