无法在Shiny仪表板中显示csv文件并为ggplot获取文件输入

时间:2015-07-23 07:54:27

标签: r ggplot2 shiny shinydashboard

我是新的闪亮我试图使用闪亮和shinydasboard制作一个应用程序。我有光泽,我创建了一个动作按钮,我用它来上传CSV文件,之后我根据这个文件制作ggplot。

问题:

  1. 我想在我的应用中显示csv文件而不是R控制台。
  2. 在执行作为绘图输入的操作后,我找不到如何获取最终的csv文件。
  3. 我的数据集示例:

          A        B     Class
        50.00    90.00     A
        50.01    91.00     A
        50.05    91.05     B
        51.50    91.09     C
        51.09    90.20     D
    

    ui.R

    ui <- dashboardSidebar(
    sidebarMenu(menuItem("choose",tabName = "choose")),
      menuItem("Plot",tabName = "Plot")
      body <- dashboardBody(
    tabItems(
      tabItem(tabName = "choose",
              fluidRow(
              actionButton("select", "select"),
     ) 
     tabItem(tabName = "plot",
              fluidRow(
                box(plotOutput("plot"))))
     )
    

    server.R

    select <- function(){
    dataframe <- read.table(file.choose(),header = TRUE, sep = "," 
    ,stringsAsFactors=FALSE)
    attach(dataframe)
    
    dataframe1 <- subset(dataframe, select = c(A,B))
    dataframe2 <- dataframe %>% mutate(variance1 = var(A)) %>% 
    mutate(variance2 = var(B))
    return(print(dataframe2))
    }
    
    server <- function(input,output){
     observeEvent(
     input$select,{
      select()
     }
     output$plot <- renderPlot({
      pd <- input$dataframe2
      pd1 <- ggplot(pd, aes(y = A, x = B, colour = Class)) +geom_point() + 
    print(pd1)
    })
     shinyApp(ui,server)
    

0 个答案:

没有答案