我正在尝试创建一个简单的闪亮应用程序,它从csv文件中获取信息并生成一个表和两个图形。内容似乎正在正确加载,但我似乎无法使输出进入指定的选项卡,使输出看起来混乱,难以阅读。任何帮助表示赞赏。提前谢谢
library(ggplot2)
library(plater)
server <- function(input, output) {
output$table1 <- renderTable({
req(input$file1)
df <- read_plate(input$file1$datapath)
if(input$disp == "head") {
return(head(df))
}
else {
return(df)
}
data <- reactive({
read_plate(input$file1$datapath)
})
})
{output$Plot1 <- renderPlot({
req(input$file1)
df <- read_plate(input$file1$datapath)
ggplot(df, aes(x=Column, y=Row, size = 20, color = "variabley")) + geom_point()
})
}
output$vx <- renderUI({
req(input$file1)
df <- read_plate(input$file1$datapath)
selectInput("variablex", "Select the (X) Variable", choices = names(df))
})
output$vy <- renderUI({
req(input$file1)
df <- read_plate(input$file1$datapath)
selectInput("variabley", "Select the (y) Variable", choices = names(df))
})
output$p <- renderPlot({
req(input$file1)
df <- read_plate(input$file1$datapath)
ggplot(df, aes(input$variablex, input$variabley, size = 20)) + geom_point()
})
}
ui <- fluidPage(
titlePanel("Enrichment Analysis"),
sidebarLayout(
sidebarPanel(
fileInput("file1", "Choose CSV File",
multiple = TRUE,
accept = c("text/csv",
"text/comma-separated-values,text/plain",
".csv")),
tags$hr(),
# Input: Checkbox if file has header ----
checkboxInput("header", "Header", TRUE),
# Input: Select separator ----
radioButtons("sep", "Separator",
choices = c(Comma = ",",
Semicolon = ";",
Tab = "\t"),
selected = ","),
# Input: Select quotes ----
radioButtons("quote", "Quote",
choices = c(None = "",
"Double Quote" = '"',
"Single Quote" = "'"),
selected = '"'),
#Checkbox
# Horizontal line ----
tags$hr(),
# Input: Select number of rows to display ----
radioButtons("disp", "Display",
choices = c(Head = "head",
All = "all"),
selected = "head")
),
mainPanel(
tabsetPanel(type = "tab",
tabPanel("Plot", fluid = TRUE,
sidebarLayout(
sidebarPanel(selectInput("colm", "Variable", choices = names(df), selected = "")),
mainPanel(
plotOutput("Plot1")
)
)
),
tabPanel("Plate"),
sidebarPanel(
uiOutput("vx"),
uiOutput("vy"),
mainPanel(plotOutput("p", width = "70%"))
),
tabPanel("Comparison"),
tabPanel("Table")),
tableOutput("table1")
)
)
)
shinyApp(ui, server )