相关疑难解决方法(0)

根据csv文件的列名创建选择列表,以便在Shiny中进行绘图

我正在尝试构建一个闪亮的应用程序,我可以上传一个csv文件,并根据列名称,填充ui左侧列(滑动条列)上的复选框.根据为y轴选择的列和为x轴选择的列,需要能够使用ggplot创建图表.

我的ui.R看起来像这样:

shinyUI(pageWithSidebar(
  headerPanel("CSV Viewer"),
  sidebarPanel(
    fileInput('file1', 'Choose CSV File',
              accept=c('text/csv', 'text/comma-separated-values,text/plain', '.csv')),
    tags$hr(),
    checkboxInput('header', 'Header', TRUE),
    radioButtons('sep', 'Separator',
                 c(Comma=',',
                   Semicolon=';',
                   Tab='\t'),
                 'Comma'),
    radioButtons('quote', 'Quote',
                 c(None='',
                   'Double Quote'='"',
                   'Single Quote'="'"),
                 'Double Quote'),

   checkboxGroupInput("variable", "Variable:", choices = names(data_set))
  ),
  mainPanel(
    tableOutput('contents')


  )
))
Run Code Online (Sandbox Code Playgroud)

Server.R看起来像这样:

shinyServer(function(input, output) {
  output$contents <- renderTable({

    # input$file1 will be NULL initially. After the user selects and uploads a 
    # file, it will be a data frame with 'name', 'size', 'type', and 'datapath' 
    # columns. The 'datapath' …
Run Code Online (Sandbox Code Playgroud)

csv plot r ggplot2 shiny

3
推荐指数
2
解决办法
5345
查看次数

标签 统计

csv ×1

ggplot2 ×1

plot ×1

r ×1

shiny ×1