Dies ist eine Frage derivated nach store input as numeric value to generate three tables in Shiny und ähnlich, aber nicht gleich, zu r shiny error Error in as.vector(x, "character") : cannot coerce type 'closure' to vector of type 'character'Shiny dynamischer Tabellenfehler
Ich will „nicht Typen‚Schließung‘zu Vektor vom Typ‚Charakter‘zwingen“ eine große Tabelle erstellen, um Erstellen Sie einige Tabellen nach dieser Tabelle in einer Shiny-App.
Hier mein MWE ist (scheint ein Problem mit dem Titel zu sein, die h3 des im UI):
Voll server.R:
#
# This is the server logic of a Shiny web application. You can run the
# application by clicking 'Run App' above.
#
# Required libraries
if (!require("pacman")) install.packages("pacman")
p_load(shiny,dplyr,DBI,ggplot2)
# Define server logic
shinyServer(
function(input, output) {
display_table <- reactive({
t <- reactive({ as.character(input$year) })
# Read the RCA matrix
long_table = tbl_df(mpg) %>% filter(year == t())
return(long_table)
})
output$year = renderText(input$year)
output$miles <- DT::renderDataTable(DT::datatable({
display_table() %>% select(manufacturer,model,cty,hwy)
}))
output$desc <- DT::renderDataTable(DT::datatable({
display_table() %>% select(manufacturer,model,trans,class)
}))
}
)
Voll ui.R:
#
# This is the user-interface definition of a Shiny web application. You can
# run the application by clicking 'Run App' above.
#
# Required libraries
if (!require("pacman")) install.packages("pacman")
p_load(shiny)
# Define UI for application that draws a histogram
shinyUI(fluidPage(
verticalLayout(
# Application title
titlePanel("ggplot2's mpg dataset example"),
mainPanel(
# User parameters
column(12,
tags$h3("Parameters"),
selectInput('year', 'Year', c("Select year",1999:2015), selected = 1999)
),
# Display tables
column(12,
#withMathJax(includeMarkdown("Theory.md")),
h3("Miles per gallon for cars made in the year",textOutput("year")),
DT::dataTableOutput("miles"),
h3("Description for cars made in the year",textOutput("year")),
DT::dataTableOutput("desc")
)
)
)
))
in Zukunft durch die Art und Weise, es wäre wirklich hilfreich, wenn Sie eine minimale Arbeitsbeispiel Post finden Sie [hier] (https://stackoverflow.com/documentation/shiny/10653/how-to-write-mcve-minimal-vollständig-und-verifizierbar-Beispiel-shiny-apps). Fügen Sie gefälschte Daten hinzu, damit andere Ihren Code ausführen können. Es erleichtert das Debuggen und hilft Ihnen, Ihr Problem zu lösen. – Florian
vielen Dank !! Ich änderte das zu einem MWE mit 'mpg' Datensatz – pachamaltese
Meine Antwort entsprechend aktualisiert. – Florian