0
関数fuzの値を掛けたい場合< - ユーザーが英語を選択するとgset_defuzzifyを2、ifを選択するとifスペイン語が選択されます。ラジオボタン(shinyapp)で選択された関数に応じて関数の値を変更する方法&
リアクティブ式を使用しようとしましたが、「shinyoutputオブジェクトからオブジェクトを読み取ることができません」というエラーが表示されました。
おかげ
P.S:I`mはまだ多分、誰かがそれを支援することができ、「fuzzy_inference」関数の入力値を取得しようとしています。
ライブラリ(光沢) ライブラリ(shinyjs) ライブラリー(セット) ライブラリ(データセット)
ui <- fluidPage(numericInput(inputId = "one", label="Type number",1, min=1, max=120),
numericInput(inputId = "two", label="Type number",1, min = 1, max=120),
numericInput(inputId = "three", label="Type number",1, min = 1, max=120),
numericInput(inputId = "four", label="Type number",1, min = 1, max=120),
textOutput("sub"), br(),
actionButton("act", "Show"),
br(),
radioButtons(inputId = "RB",label="Choose",
c("English",
"French",
"German",
"Spanish",
"None")),
textOutput("sw"),
textOutput("text")
)
server <- function(input, output){
output$text <- renderText({
RB <- switch(input$RB,
English= "You schould learn German.",
French = "You schould learn Spanish.",
German = "You schould learn English.",
Spanish = "You schould learn Portuguese.",
None ="You schould learn Polish.")
})
variables <- set(wo = fuzzy_partition(varnames = c(notMany2 = 15, enough2 = 25, many2 = 35),FUN = fuzzy_cone, radius = 10),
top = fuzzy_partition(varnames = c(notMany3 = 20, enough3 = 50, many3 = 100),FUN = fuzzy_cone, radius = 25),
c = fuzzy_partition(varnames = c(k4 = 52, k3 = 42, k2 = 32,k1 = 22), sd = 3)
)
rules <- set (fuzzy_rule(wo %is% notMany2 && top %is% notMany3
|| wo %is% notMany2 && top %is% notMany3
|| wo %is% notMany2 && top %is% notMany3
, c %is% k1),
fuzzy_rule(wo %is% notMany2 && top %is% enough3
|| wo %is% notMany2 && top %is% many3,c %is% k2))
system <- fuzzy_system(variables,rules)
fi <- fuzzy_inference(system, list(wo = 20, top= 10))
fuz <- gset_defuzzify(fi, 'centroid')
output$sub <- renderText({fuz})
z <- reactive(if(output$sub=="You schould learn German") (fuz*2))
output$sw <- renderText({z()})
}
shinyApp(ui = ui, server = server)
あなたのお返事ありがとうございますが、fuz < - gset_defuzzify(fi、 'centroid')ですので、決してすべてのテキストと等しいことはありません。その数。英語が選択されている場合は、この数字に2を掛けなければなりません。 – Anastasia
@Anastasia申し訳ありません、私はセットパッケージに慣れていません。しかし、エラーメッセージは、上記の行で 'output $ sub'を使用できないことを示しています。使用するオブジェクトを環境内で通常どおり宣言し、論理ステートメントでそのオブジェクトを使用してみてください。 – DataJack
はい、ありがとうございます。これはうまくいきます:z < - reactive(if(input $ RB == "English")(fuz * 2))最後に! – Anastasia