Shiny簡(jiǎn)介Shiny是RStudio公司開發(fā)的新包,有了它,可以用R語言輕松開發(fā)交互式web應(yīng)用。 Shiny特性
書寫本文檔初衷以下幾種情況:
ok, 吐槽結(jié)束. 1, 使用RStudio新建一個(gè)Shiny App點(diǎn)擊新建, Shiny Web App 2, 命名為shiny-download3, 運(yùn)行模型點(diǎn)擊Run App 4, 查看app5, 如何上傳數(shù)據(jù)呢目的:
shinydashboard使用指南
library(shiny)
library(data.table)
library(shinydashboard)
ui = dashboardPage(
dashboardHeader(title = "如何上傳數(shù)據(jù)"),
dashboardSidebar(
menuItem("上傳數(shù)據(jù)",tabName = "a"),
br(),
menuItem("head結(jié)果",tabName = "b"),
br(),
menuItem("summary結(jié)果",tabName = "c")
),
dashboardBody(
tabItems(
tabItem(tabName = "a",fileInput("dat","上傳csv文件",accept = ".csv")),
tabItem(tabName = "b",tableOutput('head')),
tabItem(tabName = "c",verbatimTextOutput("summary"))
)
)
)
server <- function(input, output) {
d1 <- reactive({
inFile1 <- input$dat
if (is.null(inFile1)) return(NULL)
fread(inFile1$datapath)
})
output$head <- renderTable({
dat= d1()
head(dat)
})
output$summary <- renderPrint({
dat= d1()
summary(dat)
})
}
shinyApp(ui = ui, server = server) 6, 展示
|
|