首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RShiny反应性错误

RShiny反应性错误
EN

Stack Overflow用户
提问于 2016-12-23 05:07:51
回答 0查看 110关注 0票数 0

我正在构建一个简单的RShiny应用程序来计算样本大小和功率,但我一直收到这个错误消息-警告:.getReactiveEnvironment()$currentContext中的错误:如果没有活动的反应式上下文,则不允许操作。(您尝试做了一些只能从反应式表达式或观察者内部完成的操作。)我想不出怎么解决这个问题。这是我第一次使用RShiny。如果有人能帮上忙,我真的很感激!非常感谢!

代码语言:javascript
复制
library(shiny)
ui <- fluidPage(
headerPanel("Power and Sample Size Calculator"),
fluidRow(column(12,
              wellPanel(
                helpText("Two proportions (equal sample size in each group) power/sample size analysis"),
                selectInput (inputId = "choice",
                             label = " Please Choose What You Want To Calculate",
                             c("Power","Sample Size"),selected = NULL, 
                             multiple = FALSE,
                             selectize = TRUE, width = NULL, size = NULL)
                )),
       column(4,
              wellPanel(
                conditionalPanel(
                  condition = "input$choice = Power",
                  numericInput (inputId = "tau",
                                label = "Effect Size",
                                value = "0.2",
                                min = 0, max =1),
                  numericInput (inputId = "n", 
                                label = "Sample Size in Each Group", 
                                value = "200",
                                min = 0,
                                max = 100000000),
                  sliderInput (inputId = "alpha", 
                               label = "Significance Level ⍺= ", 
                               value = "0.05",
                               min = 0.001, max = 0.10)),
                conditionalPanel(
                  condition = "input$choice=Sample Size",
                  numericInput (inputId = "tau",
                                label = "Effect Size",
                                value = "0.2",
                                min = 0, max =1),
                  sliderInput (inputId = "alpha", 
                               label = "Significance Level ⍺= ", 
                               value = "0.05",
                               min = 0.001, max = 0.10),
                  numericInput (inputId = "beta", 
                                label = "Power", 
                                value = "0.8",
                                min = 0,
                                max = 1))
                )
                ),
       column(8,
              wellPanel(
                htmlOutput("Result")
              ))
              ))


server <- function(input, output) {
choice <- switch (input$choice,
                "Power" = 1, "Sample Size" = 2)
output$Result <- renderUI({
if(choice==1){
  final=reactive({pwr.2p.test(h = input$tau, n = input$n, sig.level = input$alpha, power = )
  })
}
if(choice==2){
  final=reactive({pwr.2p.test(h = input$tau, n = , sig.level = input$alpha, power = input$beta)
})}
HTML(final)
}
)
}

 shinyApp(ui=ui, server=server)
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41291668

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档