library(shiny)
library(shinydashboard)
#>
#> Attaching package: 'shinydashboard'
#> The following object is masked from 'package:graphics':
#>
#> box
library(corrplot)
#> corrplot 0.84 loaded
library(ggplot2)
# library(reprex)
ui <- dashboardPage(
dashboardHeader(title = "F2P Mobile Game Publishing Analysis"),
dashboardSidebar(
sidebarMenu(
menuItem("Game Data Collection", tabName = "data", icon = icon("table")),
menuItem("Compartive Analysis", tabName = "chart", icon = icon("line-chart")),
menuItem("Correlation Analysis", tabName = "correlation", icon = icon("bar-chart-o"))
)),
dashboardBody(
tabItems(
# 第一个标签内容
tabItem(tabName = "data",
fluidRow(
box(title="iris数据集",status="success",
solidHeader = TRUE,collapsible=TRUE,
tableOutput("mytable")),
box(title="Game New Version Update Analysis",width = 13,status="success",
solidHeader = TRUE, collapsible=TRUE,
fileInput("file","Upload the Game New Version Update Evalution File", multiple = TRUE)),
mainPanel(
tableOutput("contents")
)
# box(title="滑动条",status="primary",solidHeader = TRUE,
# collapsible=TRUE,background="purple",
# numericInput("n","请选择要查看的数据行",value = 6))
)),
# 第二个标签内容
tabItem(tabName = "chart",
column(8,plotOutput("myplot"))),
# 第 3 个标签内容
tabItem(tabName = "correlation",
column(8,plotOutput("mycorrelationplot")))
)
)
)
server <- shinyServer(function(input,output){
dataset <- reactive({
req(input$file)
read.csv(file = input$file$datapath,
na.strings = ".",
sep = ";",
header = TRUE)
})
output$contents <- renderTable({
req(dataset())
head(dataset())
})
# 向用户界面输出iris数据表,根据input$n输出行数
output$mytable <- renderTable({
head(iris,input$n)
})
# 向用户界面输出箱线图,并根据input$outliers是否输出异常点
output$myplot <- renderPlot({
# y <- select(dataset(), IOS.New.Player.Installs, IOS.Active.Player.DAU, IOS.Revenue, IOS.Paying.Player, IOS.Returning.user)
plot.ts(dataset())
# ggplot(dataset(), aes(x=Date, y = IOS.New.Player.Installs)) +
# geom_line(dataset(), aes(x=Date,y = IOS.Revenue), color = "blue") +
# geom_line(dataset(), aes(x=Date,y = IOS.Active.Player.DAU), color = "red") +
# geom_line(dataset(), aes(x=Date,y = IOS.Paying.Player), color="pink") +
# geom_line(dataset(), aes(x=Date,y = IOS.Returning.user), color = "purple") +
# xlab('Date') +
# ylab('Numbers')+
# geom_vline(xintercept = 7)
})
# correlation plot
output$mycorrelationplot <- renderPlot({
datas <- as.numeric((dataset()))
M <- cor(datas)
corrplot.mixed(M, lower = "ellipse", upper = "number",tl.pos="lt",diag="u")
})
})
shinyApp(ui, server)
#> PhantomJS not found. You can install it with webshot::install_phantomjs(). If it is installed, please make sure the phantomjs executable can be found via the PATH variable.
Shiny applications not supported in static R Markdown documents
# M <- cor(as.numeric(iris[,c(1,2,3,4)]))
# corrplot(M, method="circle")
#
#
Created on 2021-02-21 by the reprex package (v0.3.0)
I think this is reprex format that you want.