おそらく変化するcsvファイルのリストからレンダリングされる選択入力オプションを表示する必要があります。光沢のあるUI:CSVファイルの長いリストからSelect Inputの名前を表示する - 表示方法?
ユーザは最初に、ラジオボタンを使用して、彼が検査したい詳細ビューを選択します。ここでは、選択した選択肢にパスを追加するだけで、正しいフォルダに移動します。 2番目のステップでは、ユーザーは「フルーツ」詳細ビューを選択できる必要があります。したがって、私はgsubでCSVファイルの巨大なリストをフィルタリングし、これは正常に動作しますが、名前はselect入力フィールドに表示されず、さらにエラーメッセージが表示されます。
それをより簡単にするために、コード:
ui.R
tabItem(tabName = "mainTab",
# control boxes
fluidRow(
box(
title = "Please select a fruit representation",
width = 12,
status = "info",
color = "maroon",
collapsible = FALSE,
radioButtons(
inputId = "fruit_view",
label = "",
choices = c("Top Fruit View",
"Current Fruit Split",
"Top Fruit & Value Class"),
selected = "Top Fruit View",
inline = TRUE)
)
),
fluidRow(
box(
title = "Selected Fruit:",
width = 4,
collapsible = FALSE,
selectInput(
inputId = "fruit_selection",
label = "",
choices = "")
server.R
get_fruitView <- reactive({
switch(input$fruit_view,
"Top Fruit View" = dir(
path = "data/fruits/", full.names = TRUE),
"Current Fruit Split" = dir(
path = "data/splits/", full.names = TRUE),
"Top Fruit & Value Class" = dir
(path = "data/classes/", full.names = TRUE))
})
# loading the modeled data by fruit
visible_fruits <- reactive({
fruit_choiced <- get(input$fruit_view)
fruit_choice <- view_choiced()[c(gsub(view_choiced(),
pattern = "[^_]+_[^_]+_([^_]+)_[^_]+", replacement = "\\1"))]
basename(unique(fruit_choice))
})
observe({
updateSelectInput(session, "",
choices = visible_fruits())
})
正規表現が正常に動作し、私がしたい名前を隔離表示されますが、ユーザー入力には表示されません。
ありがとうございます。
ところで私は、このエラーメッセージが表示されます。ここでは
Warning: Error in serverFuncSource: server.R returned an object of unexpected type: environment
Stack trace (innermost first):
1: shiny::runApp
Error in serverFuncSource() :
server.R returned an object of unexpected type: environment
Warning: Error in get: object 'input' not found
Stack trace (innermost first):
58: get
57: <reactive:visible_channels> [C:\Users\m.nierhoff\Desktop\AnalyseR\RAnalysen\channel-forecasting/server.R#60]
46: visible_channels
45: updateSelectInput
44: observerFunc [C:\Users\m.nierhoff\Desktop\AnalyseR\RAnalysen\channel-forecasting/server.R#69]
1: shiny::runApp
にあなたがそれをやりたいしませんが、それが見える場合、私に教えてください'updateIelect'変数を' updateSelectInput'に入れていないので、 'shiny'は更新する' selectInput'を知りません。 –
'' '$ fruit_view''を入力して' '' 'を' '使っても動作しません。 '' 'view_choiced()' 'はどこにありますか? – amrrs