如何在Shiny app中的仪表板主体中输出数据库表()

临文乍了了,彻卷兀若无。这篇文章主要讲述如何在Shiny app中的仪表板主体中输出数据库表?相关的知识,希望能为你提供帮助。
【如何在Shiny app中的仪表板主体中输出数据库表()】如何将数据库查询的结果输出到我闪亮的应用程序仪表板中。这是我的代码

library(shiny) library(shinydashboard) library(dbConnect) library(Rmysql) library(DBI) library(foreign)conn < - dbConnect( drv = RMySQL::MySQL(), dbname = "shinytest", host = "localhost", username = "root", password = "root")rs < - dbGetQuery(conn, "Select * from test; ") ui < - dashboardPage( dashboardHeader(title = "Basic dashboard"), dashboardSidebar(), dashboardBody())server < - function(input, output) {}shinyApp(ui, server)

现在代码rs < - dbGetQuery(conn, "Select * from test")确实在控制台窗口中提供输出,但我想在仪表板主体中输出它。我怎样才能做到这一点?
答案
library(shiny) library(shinydashboard) library(dbConnect) library(RMySQL) library(DBI) library(foreign)dbDisconnect(conn) conn < - dbConnect( drv = RMySQL::MySQL(), dbname = "apilogs", host = "localhost", username = "root", password = "root")rs < - dbGetQuery(conn, "Select * from test; ") ui < - dashboardPage( dashboardHeader(title = "Basic dashboard"), dashboardSidebar(), dashboardBody(box(tableOutput('table') )))server < - function(input, output) { output$table < - renderTable(rs)}dbDisconnect(conn) shinyApp(ui, server)


    推荐阅读