From d6e61438fd3ee841926c70c7ae34851077c89df6 Mon Sep 17 00:00:00 2001 From: Jakub Wajs Date: Fri, 14 Jun 2019 18:32:12 +0200 Subject: [PATCH] Structure simplification - ready MVP --- .Rhistory | 122 +++++++++++++++--------------- Server/InteractiveMapStatistics.R | 9 --- Server/Server.R | 4 +- UI/BalanceComponent.R | 12 +-- UI/InteractiveMapComponent.R | 12 --- UI/SidebarPanel.R | 18 ++--- UI/UI.R | 42 ++++------ 7 files changed, 91 insertions(+), 128 deletions(-) delete mode 100644 Server/InteractiveMapStatistics.R delete mode 100644 UI/InteractiveMapComponent.R diff --git a/.Rhistory b/.Rhistory index 532cf33..6256621 100644 --- a/.Rhistory +++ b/.Rhistory @@ -1,65 +1,4 @@ runApp() -runApp() -runApp() -View(football_data) -runApp() -runApp() -runApp() -runApp() -runApp() -runApp() -runApp() -runApp() -runApp() -runApp() -runApp() -View(football_data) -getMatchesList("England", "Scotland", football_data) -getMatchesList("England", "Scotland", football_data) %>% arrange() -getMatchesList("England", "Scotland", football_data) %>% arrange(decreasing=TRUE) -getMatchesList("England", "Scotland", football_data) %>% arrange(.,decreasing=TRUE) -getMatchesList("England", "Scotland", football_data) %>% arrange(.$date) -getMatchesList("England", "Scotland", football_data) %>% arrange(.$date, decreasing=TRUE) -getMatchesList("England", "Scotland", football_data) %>% mutate(date = as.Date(date, "%Y-%m-%d")) %>% sort(date) -getMatchesList("England", "Scotland", football_data) %>% mutate(date = as.Date(date, "%Y-%m-%d")) %>% sort(date, decreasing = TRUE) -football_data %>% select(date) -football_data %>% select(date) %>% min() -football_data %>% select(date) %>% format(date, "%Y") -football_data %>% select(date) %>% format(.$date, "%Y") -football_data %>% select(date) %>% typeof() -football_data %>% select(date) %>% format(as.Date(date, format="%Y-%m-%d"),"%Y") -test <- football_data %>% select(date) -test[1] -test %>% head(1) -test %>% head(1) %>% format(., "%Y") -test %>% head(1) %>% typeof -test %>% head(1) %>% typeof() -football_data %>% select(date) %>% min() -football_data %>% select(date) -football_data %>% select(date) %>% aggregate(., by=list(.), max) -football_data %>% min(.$date) -football_data %>% select(date) %>% summarise(min = min(date)) -football_data %>% select(date) %>% mutate(date = as.Date(date, "%Y-%m-%d")) %>% summarise(min = min(date)) -football_data %>% select(date) %>% mutate(. = as.Date(date, "%Y-%m-%d")) %>% summarise(min = min(.)) -football_data %>% select(date) %>% mutate(. = as.Date(., "%Y-%m-%d")) %>% summarise(min = min(.)) -getDateFromData <- function(matchesData) { -return( -matchesData %>% -select(date) %>% -mutate(date = as.Date(date, "%Y-%m-%d")) -) -} -getDateFromData(football_data) %>% -summarise(max = max(date)) -balance <- football_data %>% -count(winner, sort = TRUE) -return(balance) -runApp() -getDateFromData(football_data) -runApp() -runApp() -runApp() -runApp() typeof(min_date_from) getDateFromData(football_data) %>% summarise(min = min(date)) %>% as.Date() @@ -510,3 +449,64 @@ runApp() version() version packageVersion("shiny") +shiny::runApp() +test <- getMatchesForTeam("England") +test <- getMatchesForTeam(football_data"England") +test <- getMatchesForTeam(football_data, "England") +test %>% filter(home_team == "England") %>% select(.$home_score) %>% count() +test %>% filter(home_team == "England") %>% select(.$home_score) +test %>% filter(home_team == "England") +test %>% filter(home_team == "England") %>% count(home_score) +test %>% filter(home_team == "England") +test %>% filter(home_team == "England") %>% sum(home_score) +test %>% filter(home_team == "England") %>% summarise(home_score) +test %>% filter(home_team == "England") %>% aggregate(home_score) +test %>% filter(home_team == "England") %>% aggregate(home_score, sum) +test %>% filter(home_team == "England") %>% aggregate(sum) +test %>% filter(home_team == "England") %>% sum(as.numeric(.)) +test %>% filter(home_team == "England") %>% sum() +test %>% filter(home_team == "England") +test %>% filter(home_team == "England") %>% select(home_score) +test %>% filter(home_team == "England") %>% select(home_score) %>% sum() +test %>% filter(home_team != "England") %>% select(home_score) %>% sum() +test %>% select(home_score) %>% sum() +home_goals <- test %>% filter(home_team == "England") %>% select(home_score) %>% sum() +away_goals <- test %>% filter(away_team == "England") %>% select(away_score) %>% sum() +goals_scored <- tribble( +~home_goals, ~away_goals, ~overall, +home_goals, away_goals, home_goals + away_goals +) +goals_scored +test %>% filter(home_team == "England") %>% count() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +install.packages("tmap") +install.packages("tmaptools") +install.packages("leaflet") +install.packages(c("leaflet", "tmap", "tmaptools")) +runApp() +data("World") +head(World) +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() +runApp() diff --git a/Server/InteractiveMapStatistics.R b/Server/InteractiveMapStatistics.R deleted file mode 100644 index 477695d..0000000 --- a/Server/InteractiveMapStatistics.R +++ /dev/null @@ -1,9 +0,0 @@ -# -# Interactive Map Component -# - -interactiveMapStatistics <- function(input, output) { - output$interactive_world_map <- renderLeaflet( - leaflet(World) %>% addTiles() %>% setView(-93.65, 42.0285, zoom = 17) - ) -} \ No newline at end of file diff --git a/Server/Server.R b/Server/Server.R index 4940c8a..9061e19 100644 --- a/Server/Server.R +++ b/Server/Server.R @@ -6,7 +6,7 @@ source("Server/Results.R") source("Server/DataProcessor.R") source("Server/SummaryStatistics.R") -source("Server/InteractiveMapStatistics.R") +# source("Server/InteractiveMapStatistics.R") # Server logic server <- function(input, output) { @@ -21,5 +21,5 @@ server <- function(input, output) { resultsWithPagination(input, output) # Tab 3 - interactiveMapStatistics(input, output) + # interactiveMapStatistics(input, output) } diff --git a/UI/BalanceComponent.R b/UI/BalanceComponent.R index 5d1c463..17c4a7a 100644 --- a/UI/BalanceComponent.R +++ b/UI/BalanceComponent.R @@ -1,15 +1,15 @@ # Balance component -balanceComponent <- function(pieChartSize, barplotSize) +balanceComponent <- function() { - fluidRow( - column(barplotSize, - wellPanel( + tabsetPanel( + tabPanel("Bar graph", + wellPanel( plotOutput("balance") ) ), - column(pieChartSize, - wellPanel( + tabPanel("Pie chart", + wellPanel( plotOutput("balancePieChart") ) ) diff --git a/UI/InteractiveMapComponent.R b/UI/InteractiveMapComponent.R deleted file mode 100644 index 001ee91..0000000 --- a/UI/InteractiveMapComponent.R +++ /dev/null @@ -1,12 +0,0 @@ -# -# Interactive map component -# - -interactiveMapComponent <- function(rowSize) -{ - fluidRow( - column(rowSize, - leafletOutput("interactive_world_map") - ) - ) -} \ No newline at end of file diff --git a/UI/SidebarPanel.R b/UI/SidebarPanel.R index 590bd57..23c6ac1 100644 --- a/UI/SidebarPanel.R +++ b/UI/SidebarPanel.R @@ -18,19 +18,19 @@ teamsSidebarPanel <- function() { start = min_date_from, end = max_date_to, min = min_date_from, - max = max_date_to), - dropdownButton( - label = "Tournament types", - circle = FALSE, + max = max_date_to) + #dropdownButton( + # label = "Tournament types", + # circle = FALSE, #radioButtons("tournament_all", # "Select:", # choices = c("All", "None"), # selected = "All"), - checkboxGroupInput("tournament_type", - "Tournament type:", - choices = tournament_types, - selected = tournament_types) - ) + # checkboxGroupInput("tournament_type", + # "Tournament type:", + # choices = tournament_types, + # selected = tournament_types) + #) ) ) ) diff --git a/UI/UI.R b/UI/UI.R index 49c862e..d3c5a17 100644 --- a/UI/UI.R +++ b/UI/UI.R @@ -5,7 +5,6 @@ # Import files source("UI/SidebarPanel.R") source("UI/BalanceComponent.R") -source("UI/InteractiveMapComponent.R") # UI ui <- navbarPage( @@ -56,38 +55,23 @@ ui <- navbarPage( teamsSidebarPanel() ), column(9, - tabsetPanel( - tabPanel( - "Charts", - balanceComponent(6, 6), - fluidRow( - DT::dataTableOutput("results_pagination") - ) + fluidRow( + column( + 6, + balanceComponent() ), - tabPanel( - "Summary" + column( + 6 + ) + ), + fluidRow( + column( + 12, + DT::dataTableOutput("results_pagination") ) ) ) ) - ), - - # Tab 3 - tabPanel("Overall", - fluidRow( - column(12, - tabsetPanel( - tabPanel( - "Map", - interactiveMapComponent(12) - ), - tabPanel( - "Summary" - ), - tabPanel( - "All matches" - ) - )) - )) + ) ) \ No newline at end of file