光沢のあるアプリでインタラクティブ プロットのチャート タイトルを決定するために作成した関数を使用して問題が発生しています。アプリの外部では機能しますが、内部では機能しません
エラー: Error in if: argument is of length zero
UI
plotlyOutput("plot"),
column(3,
uiOutput("keysk"), checkboxInput("key1", "1st Key"), checkboxInput("multi", "Multiple", value = F)),
column(3,
uiOutput("keysk2"), checkboxInput("key2", "2nd Key"), checkboxInput("multi2", "Multiple", value = F)),
column(3,
uiOutput("keysk3"), uiOutput("key3rdbox"), checkboxInput("multi3", "Multiple", value = F))
サーバ
output$plot <- renderPlotly({
*tsibble of your own*() %>% autoplot()
+ labs(title =
titlefinder(key1= input$key1, key2 =input$key2, key3=input$key3, keysk= input$keysk, keysk2=input$keysk2, keysk3=input$keysk3) )
})
output$keysk = renderUI({
req(length(keyvar() >0) )
req(input$key1 == T)
file_to_read <- input$file
selectizeInput("keysk", "Key1" choices = as.list( unique(*Your Tsibble*()[key_vars(*Your Tsibble*())[1]]) ) , multiple = input$multi)
})
output$keysk2 = renderUI({
req(length(keyvar() >1) )
req(input$key2 == T)
file_to_read <- input$file
selectizeInput("keysk2", "Key2", choices = as.list( unique(*Your Tsibble*()[key_vars(*Your Tsibble*())[2]]) ) , multiple = input$multi2)
})
output$keysk3 = renderUI({
req(length(keyvar() >2) )
req(input$key3rdbox == T)
file_to_read <- input$file
selectizeInput("keysk3", "Key3", choices = as.list( unique(*Your Tsibble*()[key_vars(*Your Tsibble*())[3]]) ) , multiple = input$multi3)
})
output$key3rdbox = renderUI({
file_to_read <- input$file
checkboxInput("key3rdbox", "3rd Key")
})
外部アプリをテストするためのセットアップ:
input <- c()
input <- as.list(input)
input$keysk <- "New South Wales"
input$keysk2 <- "Liquor retailing"
input$keysk3 <- "Liquor retailing"
input$key1 <- F
input$key2 <- F
input$key3 <- F
関数:
titlefinder <- function(key1, key2, key3, keysk, keysk2, keysk3){
if(key1==T & key2==F & key3==F){title = keysk}
if(key1==T & key2==T & key3==F){title = paste(keysk, keysk2)}
if(key1==T & key2==T & key3==T){title = paste(keysk, keysk2, keysk3)}
if(key1==F & key2==T & key3==F){title = paste(keysk2)}
if(key1==F & key2==T & key3==T){title = paste(keysk2, keysk3)}
if(key1==F & key2==F & key3==T){title = paste(keysk3)}
if(key1==F & key2==F & key3==F){title = ""}
return(title)
}
使用例 外 ピカピカ
input$keysk <- "New South Wales"
input$keysk2 <- "Liquor retailing"
input$keysk3 <- "Liquor retailing"
input$key1 <- T
input$key2 <- T
input$key3 <- F
*Your own tsibble* %>% autoplot() + labs(title = titlefinder(input$key1, input$key2, input$key3, input$keysk1, input$keysk2, input$keysk3) )
出力例/光沢のある所望の出力
[1] "New South Wales Liquor retailing"
光沢のあるアプリに入れると、これが機能しない理由を誰か説明できますか? (必要に応じてアプリ コードの詳細を提供できます)