【发布时间】:2020-09-10 12:47:34
【问题描述】:
我想使用下面的代码输出一个仪表板,左侧有 2 个面板(顶部面板:输入文件;底部面板:动作图)和右侧的绘图(主页)。目前,代码输出仪表板顶部的两个面板和底部的绘图,这不是我想要的。我是 Rshiny 的新手,需要帮助。
代码:
library(shiny)
library(pheatmap)
# Define UI for dataset viewer app ----
ui <- fluidPage(
# App title ----
titlePanel("plot"),
# Sidebar layout with input and output definitions ----
sidebarLayout(
# Sidebar panel for inputs ----
sidebarPanel("Sidebar panel",
# Input: Selector for choosing dataset ----
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")
),
tags$hr(),
checkboxInput("header", "Header", TRUE)
),
# tags$hr(),
sidebarPanel('get heatmap',
actionButton('getHmap', 'get heatmap'))
),
# Main panel for displaying outputs ----
mainPanel("Plot",
#column(6,
plotOutput("themap"),
tableOutput("table.output"))
#)
)
server = function(input, output, session) {
a <- reactive({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
tbl <- read.csv(inFile$datapath, header=input$header) #, sep=input$sep, dec = input$dec)
return(tbl)
})
output$table.output <- renderTable({
a()
})
plotdata <- eventReactive(input$getHmap, {
a <- as.matrix(a()[-1])
row.names(a) <- a()$ID
a[is.na(a)] <- 0
a
})
output$themap = renderPlot({
pheatmap(plotdata())
})
}
shinyApp(ui, server)
有谁知道如何很好地使用 Rshiny 流体页面和列并可以提供帮助?
【问题讨论】:
标签: r shiny shinydashboard shinyapps shiny-reactivity