0
我想提供inputselect依赖上传的文件(fileInput)的“选择”。在下面的示例中,我想要as.list(mydata[1, 1:5])
作为输入选择选项的值。稍后,子集值将是动态的,不会在此显示。闪亮:更新inFile的更改selectinput
我试图在论坛提出了若干方案(反应,观察,reactiveValue及其组合),但没有成功。
我的脚本部分运行,但是我需要刷新页面以获取上传的“选项”并重新加载文件。
server.R
shinyServer(function(input, output, session) {
output$contents <- renderDataTable({
inFile <<- input$SoftRecom
if (is.null(inFile))
return(NULL)
filedatapath <<- reactive({inFile$datapath})
mydata <<- read.csv(filedatapath(), header = TRUE, sep = ',')
mydata
})
mychoices <<- reactive({
mydata
print(mydata)
})
output$vg <- renderUI({
selectInput("vg", label = p("goal", style = "color:#FFA500"),
mychoices()[1,1:5], selected = 1)
})
output$vp <- renderUI({
selectInput("procedure", label = p("procedure", style = "color:#FFA500"),
choices = c("proecudures"), selected = 1)
})
output$vm <- renderUI({
selectInput("procedure", label = p("procedure", style = "color:#FFA500"),
choices = c("ChIP-seq"), selected = 1)
})
})
ui.R
shinyUI(fluidPage(theme = "bootstrap.css",
titlePanel("simple software recommendation sytem"),
sidebarLayout(
sidebarPanel(
fileInput('SoftRecom', 'choose dataset'),
uiOutput("vg"), # variable goal
uiOutput("vp"), # variable procedure
uiOutput("vm") # variable method
),
mainPanel(
dataTableOutput('contents')
)
)
))
我见过很多例子,在论坛的答案,非常接近(甚至匹配),我的问题。对不起,因为太钝了。如果有人能指出我的问题,我会非常感激。
Jay