0
R 반짝이를 사용하여 APP를 만들려고합니다. 데이터 (.csv 파일)를 업로드하고 싶습니다. 그런 다음 CSV 파일의 열 이름을 드롭 다운 메뉴에 채 웁니다. 나는 그것을 할 수 없다.R 반짝이에서 드롭 다운 메뉴를 동적으로 채울 수 없습니다
아래의 코드를 참조하십시오 :
---- server.r을 -----
library(shiny)
options(shiny.maxRequestSize = 32*1024^2)
shinyServer(
function(input, output){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
read.table(file=file1$datapath,head=TRUE,sep=",")
})
output$sum <- renderTable({
if(is.null(data())){return()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return()}
data()
})
# the following renderUI is used to dynamically generate the tabsets when the file is loaded. Until the file is loaded, app will not show the tabset.
output$tb <- renderUI({
if(is.null(data()))
h5("no file loaded")
else
tabsetPanel(tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum")))
})
output$col <- renderUI({
selectInput("phenomena", "Select the Phenomena", names(data))
})
})
----- ui.R -----
library(shiny)
shinyUI(fluidPage(
titlePanel("Hotspot Analysis of EnviroCar Data"),
sidebarLayout(
sidebarPanel(
# uploading the file
fileInput("file","Upload *.csv file"), # fileinput() function is used to get the file upload contorl option
uiOutput("col")
),
mainPanel( uiOutput("tb"))
)
))