Показать две таблицы в одной вкладке - PullRequest
0 голосов
/ 03 апреля 2020

Я пытаюсь получить две таблицы на одной странице вверху. Я хочу отобразить заголовок таблицы данных, которую мы загружаем внизу. Я написал небольшое имя функции basic_eda, где она просто даст сводку данные, которые были загружены. Запустив это, я могу отобразить голову, но не могу отобразить сводку. Я получаю сообщение об ошибке

метод по умолчанию не реализован для типа 'symbol'

I пробовал разные способы сохранить renderTable, но не смог добиться желаемого результата.

library(shiny)
library(shinydashboard)
library(Hmisc)
library(funModeling)
library(tidyverse)
library(dplyr)
basic_eda <- function(data)
{
  glimpse(data)
  df_status(data)
  freq(data)
  profiling_num(data)
}


ui <- dashboardPage(
  dashboardHeader(title = "Testing"),
  dashboardSidebar(
    sidebarMenu(
      menuItem("Data Description", tabName = "Data Description", icon = icon("database")),
      menuItem("Exproratory Data Analysis", tabName = "Exproratory Data Analysis", icon = icon("dashboard"))
    )
  ),
  dashboardBody(
    sidebarLayout(
      sidebarPanel(
        width = 3,
        # Input: Select a file ----
        fileInput("file1", "Choose CSV File",
                  multiple = FALSE,
                  accept = c("text/csv",
                             "text/comma-separated-values,text/plain",
                             ".csv",options(shiny.maxRequestSize=100*1024^2)),width = 200),

        # Horizontal line
        tags$hr(),
        checkboxInput("header", "Header", TRUE),
        radioButtons("sep", "Separator",
                     choices = c(Comma = ",",
                                 Semicolon = ";",
                                 Tab = "\t"),
                     selected = ","),
        radioButtons("quote", "Quote",
                     choices = c(None = "",
                                 "Double Quote" = '"',
                                 "Single Quote" = "'"),
                     selected = '"'),
        # Input: Select number of rows to display ----
        radioButtons("disp", "Display",
                     choices = c(Head = "head",
                                 All = "all"),
                     selected = "head"),


        radioButtons("Sum", "Summary",
                     choices = c(Summary = "summary"),
                     selected = "summary"),


      ),
      mainPanel(
        # Output: Data file ----
        tableOutput("contents"),
        tableOutput("testing")
      )

    )
  )
)


server <- function(input, output, session) {
  output$contents <- renderTable({
    req(input$file1)
    tryCatch(
      {
        df <- read.csv(input$file1$datapath,
                       header = input$header,
                       sep = input$sep,
                       quote = input$quote)
      },
      error = function(e) {
        stop(safeError(e))
      }
    )
    if(input$disp == "head") {
      return(head(df,10)) 
    }
    else {
      return(df)
    }
  })

  tags$hr()

  output$testing <-  renderTable({
    df<- df
    if(input$Sum == "summary") {
      return(basic_eda(df)) 
    }
    else {
      return(df)
    }

  })



}


shinyApp(ui, server)
...