From fae00e7f36b230386800a3038ee9c53cfea6a409 Mon Sep 17 00:00:00 2001 From: ibidyouadu Date: Wed, 2 Feb 2022 21:26:49 -0500 Subject: [PATCH] add fivethirtyeight theme to some plots --- global.R | 1 + liftboard.Rproj | 13 +++++++++++++ server.R | 14 ++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 liftboard.Rproj diff --git a/global.R b/global.R index 83e39f0..2483cfc 100644 --- a/global.R +++ b/global.R @@ -4,6 +4,7 @@ library(dplyr) library(tidyr) library(readr) library(fmsb) +library(ggthemes) lifts <- read_csv('data/lifts.csv') lifts <- rename(lifts, Weight = `Weight (lbs)`) diff --git a/liftboard.Rproj b/liftboard.Rproj new file mode 100644 index 0000000..8e3c2eb --- /dev/null +++ b/liftboard.Rproj @@ -0,0 +1,13 @@ +Version: 1.0 + +RestoreWorkspace: Default +SaveWorkspace: Default +AlwaysSaveHistory: Default + +EnableCodeIndexing: Yes +UseSpacesForTab: Yes +NumSpacesForTab: 2 +Encoding: UTF-8 + +RnwWeave: Sweave +LaTeX: pdfLaTeX diff --git a/server.R b/server.R index 6dcacbd..7ae1586 100644 --- a/server.R +++ b/server.R @@ -20,18 +20,23 @@ shinyServer(function(input, output) { output$exercises_plot <- renderPlot({ if (input$metric == 'Sets') { - ggplot(data = setsData()) + + p <- ggplot(data = setsData()) + geom_bar(mapping = aes(x=Exercise, weight=Sets), fill = '#00aaaa', color = 'black') + ylab('Sets') } else { - ggplot(data = selectedData()) + + p <- ggplot(data = selectedData()) + geom_bar(mapping = aes(x=Exercise, weight=!!sym(input$metric)), fill = '#00aaaa', color = 'black') + ylab(input$metric) - }}) + } + + p + + theme_fivethirtyeight() + + theme(axis.text.x = element_text(angle = 30, hjust=1)) + }) sumBreakdown <- reactive({ if(input$metric == 'Sets') { @@ -90,7 +95,8 @@ shinyServer(function(input, output) { output$history_plot <- renderPlot({ ggplot(data = historyData(), mapping = aes(x=Date, y=!!sym(input$metric))) + geom_line() + - geom_point() + geom_point() + + theme_fivethirtyeight() }) }) -- 2.43.0