0
で新しい変数を作成
ui.R:コンディショニングとシャイニー
library(shiny)
shinyUI(fluidPage(
checkboxGroupInput("Check1",label=h4 ("Coin Type:"), choices = c("Fair","Unfair (p = 60% for heads)"))
))
server.R:
library(shiny)
shinyServer(function(input, output) {
if (input$Check1 == "Fair"){
x <- 1
output$Value <- renderTable(as.data.frame(x))
} else {
x <- 5
output$Value <- renderTable(as.data.frame(x))
}
})
これは非常に単純でなければなりません:2つのチェックがあるはずですボックス。 "Fair"がチェックされている場合は、x
に値1を与えます。それ以外の場合は、5.データフレームに表示します。
問題は、変数x
を割り当てていると思います。
Warning: Error in .getReactiveEnvironment()$currentContext: Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
Stack trace (innermost first):
44: .getReactiveEnvironment()$currentContext
43: .subset2(x, "impl")$get
42: $.reactivevalues
41: $ [-- this has a folder directory --]
40: server [-- this has a folder directory --]
1: runApp
Error in .getReactiveEnvironment()$currentContext() :
Operation not allowed without an active reactive context. (You tried to do something that can only be done from inside a reactive expression or observer.)
[私は上記41
と40
を省略していることに注意してください]:ここで私は取得エラーです。
どのようにこの問題に対処しますか?検索で何も表示されず、reactiveValues
の使い方が分かりません。