Hello,
Could you please help mi find an error? When I start the application, I have a message : "ERROR: An argument is missing, and there is no default value specified".
library(shiny)
library(ggvis)
library(googleVis)
library(dplyr)
library(DT)
library(tidyr)
games=read.csv("C:/Users/****/OneDrive/do/games.csv")
games$ID <- 1:nrow(games)
games=games[!(games$Year=="N/A"),]
shinyServer(function(input, output) {
game= reactive({
game = games %>%
filter(Year >= input$Year[1],
Year <= input$Year[2],
Platform == input$Platform,
Genre == input$Genre,
Publisher == input$Publisher)
game=as.data.frame(game)
})
game_tooltip <- function(x) {
if (is.null(x)) return(NULL)
if (is.null(x$ID)) return(NULL)
data <- isolate(game())
olymp <- games[games$ID == x$ID, ]
paste0("<b>", olymp$Name, "</b><br>",
"year: ", olymp$Year, "<br>",
"age: ", olymp$Publisher, "<br>",
"sport: ",olymp$Platform, "<b>")
}
vis <- reactive({
xvar_name <- names(axis_vars)[axis_vars == input$xvar]
yvar_name <- names(axis_vars)[axis_vars == input$yvar]
xvar <- prop("x", as.symbol(input$xvar))
yvar <- prop("y", as.symbol(input$yvar))
game %>%
ggvis(x = xvar, y = yvar) %>%
layer_points(size := 50, size.hover := 200,
fill = ~Platform, key := ~ID) %>%
add_tooltip(game_tooltip, "hover") %>%
add_axis("x", title = xvar_name, format="####") %>%
add_axis("y", title = yvar_name, format="####") %>%
add_legend("fill", title = "Platform", values = c("PC", "PS4","PS3","X360","PSP","XOne")) %>%
scale_nominal("fill", domain = c("PC", "PS4","PS3","X360","PSP","XOne"),
range = c("orange", "gray","brown","black","pink","blue")) %>%
set_options(width = 500, height = 500)
})
vis %>% bind_shiny("plot1")
# number of data
output$n_gamer <- renderText({
nrow(game())
})
# table
output$table <- DT::renderDataTable({
game()
})
})
library(shiny)
library(ggvis)
library(dplyr)
library(DT)
actionLink <- function(inputId, ...) {
tags$a(href='javascript:void',
id=inputId,
class='action-button',
...)
}
fluidPage(
titlePanel("Games"),
fluidRow(
column(3,
wellPanel(
h4("Filter"),
sliderInput("Year", "Year released", 2000, 2016, value = c(1980, 2020), sep = ""),
selectInput("Platform", "Platform:",c("PS","X360", "PS3", "Wii" ,"PS2" , "DS", "PC", "N64", "PSP", "3DS", "GC", "XB" , "GBA" , "PSV" , "NES" , "PS4", " XOne", "SNES", "2600", "WiiU", "SAT", "GB"
,"NG" , "GEN", "PCFX DC" ,"3DO" , "WS" ,"TG16", "SCD", "GG" ) ),
selectInput("Genre","Genre:",c("Racing", "Action" , "Shooter" , "Misc", "Adventure", " Sports", "Puzzle", "Simulation", "Platform", "Role-Playing"
, "Strategy","Fighting" )),
selectInput("Publisher","Publisher:",as.list(games["Publisher"]))
),
wellPanel(
selectInput("xvar", "X-axis variable", axis_vars, selected = "NA_Sales"),
selectInput("yvar", "Y-axis variable", axis_vars, selected = "JP_Sales")
)
),
mainPanel(
tabsetPanel(type = "tabs",
tabPanel("Plot",
ggvisOutput("plot1")),
tabPanel("Table",
dataTableOutput("table")),
),
column(9,
wellPanel(
span("Number of data:",
textOutput("n_gamer")
)
)
)
)
)
)
global.R
axis_vars <- c(
"NA_Sales" = "NA_Sales",
"EU_Sales"="EU_Sales",
"JP_Sales"="JP_Sales",
"Other_Sales"="Other_Sales"
)