【问题标题】:R shiny environmentsR闪亮的环境
【发布时间】:2015-05-30 03:30:59
【问题描述】:

我对 Shiny 应用程序中的环境范围有点困惑。我读到server.RshinyServer 函数之外定义的任何对象都可用于所有用户会话。但是,如果我使用assign 函数和envir=.GlobalEnv 选项创建一个对象,该对象是否可用于其他用户会话?

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

R Shiny 用户会话中的全局环境是在 shinyServer 函数中创建所有对象的环境的父环境吗?

感谢任何帮助澄清这一点。

【问题讨论】:

    标签: r environment


    【解决方案1】:

    下面我举了一个例子,在闪亮的不同环境对应的位置上使用 cmets。其实很简单。

    另请参阅 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.
    
        })
     })
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-10
      • 1970-01-01
      • 2017-01-15
      • 2023-03-31
      • 2020-07-23
      • 1970-01-01
      相关资源
      最近更新 更多