【发布时间】:2021-09-20 06:28:12
【问题描述】:
我正在尝试制作一个应用程序,该应用程序将通过将 csv 文件上传到其中为您呈现图表,您可以在其中选择要绘制的变量。事实是我不知道我做错了什么,因为该应用程序不会呈现图表。有什么想法或建议吗?
代码是:
library(shiny)
library(echarts4r)
ui <- fluidPage(
selectInput('mydropdown', label = 'Selección de variables', choices = 'Aún no hay variables a escoger'),
selectInput('mydropdown1', label = 'Selección de variables', choices = 'Aún no hay variables a escoger'),
fileInput('myfileinput', label = 'Archivo a usar', accept = c(".csv")),
echarts4rOutput("plot")
)
#Server
server <- function(input, output, session) {
observeEvent(input$myfileinput, {
mytable <- read.csv(input$myfileinput$datapath)
updateSelectInput(session, "mydropdown", label = "Select", choices = colnames(mytable))
updateSelectInput(session, "mydropdown1", label = "Select", choices = colnames(mytable))
})
mytable <- renderEcharts4r({
myfileinput |>
e_charts(input$mydropdown) |>
e_line(input$mydropdown1)
})
}
shinyApp(ui, server)
【问题讨论】: