R 如何在添加不同输入后制作闪亮的应用程序显示图表
我想在我的闪亮应用程序上寻求一些帮助,我已经花了一整天的时间在它上面,但我无法让它工作。我的应用程序应该显示不同的游戏销售图表。我能够创建工作版本,但由于我添加了selectInput,它拒绝显示任何图表,我也没有办法解释为什么会这样。我将非常感谢任何帮助。 提前非常感谢 代码如下:R 如何在添加不同输入后制作闪亮的应用程序显示图表,r,shiny,R,Shiny,我想在我的闪亮应用程序上寻求一些帮助,我已经花了一整天的时间在它上面,但我无法让它工作。我的应用程序应该显示不同的游戏销售图表。我能够创建工作版本,但由于我添加了selectInput,它拒绝显示任何图表,我也没有办法解释为什么会这样。我将非常感谢任何帮助。 提前非常感谢 代码如下: library(shiny) library(ggplot2) #ui.R ui <- fluidPage( titlePanel(""), sidebarLayout(
library(shiny)
library(ggplot2)
#ui.R
ui <- fluidPage(
titlePanel(""), sidebarLayout(
sidebarPanel(
helpText(""),
tags$hr(),
fileInput("file","Where csv is located: "),
selectInput("att", "Select an attribute", choices=c("NA Sales","Global Sales","EU Sales","Japan Sales","Other Sales"),selected="Global Sales",multiple=FALSE,selectize=TRUE)),
mainPanel(
uiOutput("tb"),
plotOutput("line")
)
)
)
#server.R
server <- function(input,output){
data <- reactive({
file1 <- input$file
if(is.null(file1)){return()}
read.csv(file=file1$datapath, sep=",", header=TRUE)})
output$filedf <- renderTable({
if(is.null(data())){return ()}
input$file
})
output$sum <- renderTable({
if(is.null(data())){return ()}
summary(data())
})
output$table <- renderTable({
if(is.null(data())){return ()}
data()
})
output$line <- renderPlot({
if (is.null(data())) { return() }
})
output$map1 <- renderPlot({
if (is.null(input$att)){ warning("select at least one attribute"); return(NULL)}
else if(identical(input$att,"Global Sales")){
print(ggplot(data(), aes(table$Genre, table$Global_Sales))
+ geom_col()
+ theme(axis.text.x = element_text(angle=90, hjust=1))
+ facet_wrap(~Platform)
)
}
else if(identical(input$att,"EU Sales")){
print(ggplot(data(), aes(table$Genre, table$Global_Sales))
+ geom_col()
+ theme(axis.text.x = element_text(angle=90, hjust=1))
+ facet_wrap(~Platform)
)
}
else if(identical(input$att,"Japan Sales")){
print(ggplot(data(), aes(table$Genre, table$Global_Sales))
+ geom_col()
+ theme(axis.text.x = element_text(angle=90, hjust=1))
+ facet_wrap(~Platform)
)
}
else if(identical(input$att,"NA Sales")){
print(ggplot(data(), aes(table$Genre, table$Global_Sales))
+ geom_col()
+ theme(axis.text.x = element_text(angle=90, hjust=1))
+ facet_wrap(~Platform)
)
}
else if(identical(input$att,"Other Sales")){
print(ggplot(data(), aes(table$Genre, table$Global_Sales))
+ geom_col()
+ theme(axis.text.x = element_text(angle=90, hjust=1))
+ facet_wrap(~Platform)
)
}
})
output$tb <- renderUI({if(is.null(data())) h5()
else
tabsetPanel(tabPanel("About file", tableOutput("filedf")),tabPanel("Data", tableOutput("table")),tabPanel("Summary", tableOutput("sum")))
})
}
shinyApp(ui = ui, server = server)
库(闪亮)
图书馆(GG2)
#用户界面
ui您的ui没有任何plotOutput('map1')
您的ui没有任何plotOutput('map1')