From a5619142f830c9a024c29331aad8a6c17b6fe754 Mon Sep 17 00:00:00 2001 From: ibidyouadu Date: Wed, 2 Feb 2022 19:14:30 -0500 Subject: [PATCH] fix historical plots --- .Rhistory | 5 + .Rproj.user/688FCC69/pcs/files-pane.pper | 2 +- .Rproj.user/688FCC69/pcs/source-pane.pper | 2 +- .../688FCC69/pcs/windowlayoutstate.pper | 2 +- .Rproj.user/688FCC69/sources/prop/6815E065 | 4 +- .Rproj.user/688FCC69/sources/prop/D4824927 | 4 +- .../sources/s-FA01BD99/5C556F75-contents | 11 --- .../sources/s-FA01BD99/63C95A32-contents | 5 - .../688FCC69/sources/s-FA01BD99/A690A505 | 26 ----- .../sources/s-FA01BD99/A690A505-contents | 47 --------- .../688FCC69/sources/s-FA01BD99/BA0BC75E | 26 ----- .../sources/s-FA01BD99/BA0BC75E-contents | 95 ------------------- .../sources/s-FA01BD99/F11D91F6-contents | 0 .../688FCC69/sources/s-FA01BD99/FEEDDA97 | 27 ------ .../sources/s-FA01BD99/FEEDDA97-contents | 13 --- .../688FCC69/sources/s-FA01BD99/lock_file | 0 .Rproj.user/shared/notebooks/paths | 3 +- .gitignore | 1 + server.R | 4 +- 19 files changed, 18 insertions(+), 259 deletions(-) delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/5C556F75-contents delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/63C95A32-contents delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/A690A505-contents delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E-contents delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/F11D91F6-contents delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97-contents delete mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/lock_file diff --git a/.Rhistory b/.Rhistory index eabc57c..6d20a40 100644 --- a/.Rhistory +++ b/.Rhistory @@ -101,3 +101,8 @@ dir getwd() setwd('Documents/projects/liftboard/') rsconnect::deployApp() +install.package('rsconnect') +install.packages('rsconnect') +rsconnect::setAccountInfo(name='ibidyouadu', token='71ED4FEDAF57251FDDD0C73B2F51A5D4', secret='3sFYCmMbFk+xEZKLP9EcEat+PVAzvK9Jm5fs8QqT') +getwd() +rsconnect::deployApp() diff --git a/.Rproj.user/688FCC69/pcs/files-pane.pper b/.Rproj.user/688FCC69/pcs/files-pane.pper index 41544a4..5c95cb6 100644 --- a/.Rproj.user/688FCC69/pcs/files-pane.pper +++ b/.Rproj.user/688FCC69/pcs/files-pane.pper @@ -5,5 +5,5 @@ "ascending": true } ], - "path": "~/Documents/projects" + "path": "~/Documents/projects/liftboard" } \ No newline at end of file diff --git a/.Rproj.user/688FCC69/pcs/source-pane.pper b/.Rproj.user/688FCC69/pcs/source-pane.pper index ddca97d..a528f3b 100644 --- a/.Rproj.user/688FCC69/pcs/source-pane.pper +++ b/.Rproj.user/688FCC69/pcs/source-pane.pper @@ -1,3 +1,3 @@ { - "activeTab": 2 + "activeTab": -1 } \ No newline at end of file diff --git a/.Rproj.user/688FCC69/pcs/windowlayoutstate.pper b/.Rproj.user/688FCC69/pcs/windowlayoutstate.pper index 381ddd5..e201520 100644 --- a/.Rproj.user/688FCC69/pcs/windowlayoutstate.pper +++ b/.Rproj.user/688FCC69/pcs/windowlayoutstate.pper @@ -1,7 +1,7 @@ { "left": { "splitterpos": 338, - "topwindowstate": "NORMAL", + "topwindowstate": "HIDE", "panelheight": 809, "windowheight": 847 }, diff --git a/.Rproj.user/688FCC69/sources/prop/6815E065 b/.Rproj.user/688FCC69/sources/prop/6815E065 index 5785522..807138d 100644 --- a/.Rproj.user/688FCC69/sources/prop/6815E065 +++ b/.Rproj.user/688FCC69/sources/prop/6815E065 @@ -1,6 +1,6 @@ { "source_window_id": "", "Source": "Source", - "cursorPosition": "8,0", - "scrollLine": "0" + "cursorPosition": "31,49", + "scrollLine": "28" } \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/prop/D4824927 b/.Rproj.user/688FCC69/sources/prop/D4824927 index 5785522..95b7c89 100644 --- a/.Rproj.user/688FCC69/sources/prop/D4824927 +++ b/.Rproj.user/688FCC69/sources/prop/D4824927 @@ -1,6 +1,6 @@ { "source_window_id": "", "Source": "Source", - "cursorPosition": "8,0", - "scrollLine": "0" + "cursorPosition": "85,28", + "scrollLine": "77" } \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/5C556F75-contents b/.Rproj.user/688FCC69/sources/s-FA01BD99/5C556F75-contents deleted file mode 100644 index 2ecad0f..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/5C556F75-contents +++ /dev/null @@ -1,11 +0,0 @@ -x <- 2 -if (x == 3) { - print("is 3!") -} else if (x == 2 | x < 0) { - print("is 2!") -} else if (x > 0) { - print('is greater than 0!') -} else { - print('dfsdfs') -} - diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/63C95A32-contents b/.Rproj.user/688FCC69/sources/s-FA01BD99/63C95A32-contents deleted file mode 100644 index 2129631..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/63C95A32-contents +++ /dev/null @@ -1,5 +0,0 @@ -library/ -local/ -lock/ -python/ -staging/ diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 b/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 deleted file mode 100644 index e18e44c..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "A690A505", - "path": "~/Documents/projects/liftboard/ui.R", - "project_path": "ui.R", - "type": "r_source", - "hash": "0", - "contents": "", - "dirty": false, - "created": 1618861938496.0, - "source_on_save": false, - "relative_order": 1, - "properties": { - "source_window_id": "", - "Source": "Source", - "cursorPosition": "8,0", - "scrollLine": "0" - }, - "folds": "", - "lastKnownWriteTime": 1619130953, - "encoding": "UTF-8", - "collab_server": "", - "source_window": "", - "last_content_update": 1619130953550, - "read_only": false, - "read_only_alternatives": [] -} \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505-contents b/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505-contents deleted file mode 100644 index 3d4f7ae..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505-contents +++ /dev/null @@ -1,47 +0,0 @@ -# -# This is the user-interface definition of a Shiny web application. You can -# run the application by clicking 'Run App' above. -# -# Find out more about building applications with Shiny here: -# -# http://shiny.rstudio.com/ -# - - - -# Define UI for application that draws a histogram -shinyUI(fluidPage( - - # Application title - titlePanel("Lifts data"), - - # Sidebar with a slider input for number of bins - sidebarLayout( - sidebarPanel( - conditionalPanel(condition = "input.tabs == 'Exercises' | - input.tabs == 'Workout History'", - selectInput(inputId = "muscles", - label = "Muscle Group", - choices = lifts$Category %>% - unique() %>% - sort())), - radioButtons(inputId = "metric", - label = "Data to display", - choices = c("Reps", - "Sets", - "Weight"))), - - # Show a plot of the generated distribution - mainPanel( - tabsetPanel(type = "tabs", id = "tabs", - tabPanel(title = "Exercises", - # conditionalPanel(condition = "input.metric == 'Reps' | input.metric == 'Weight'", - plotOutput(outputId = 'exercises_plot')), - # conditionalPanel(condition = "input.metric == 'Sets'"), - # plotOutput(outputId = 'exercises_sets_plot')), - tabPanel(title = "Muscles Breakdown", - plotOutput(outputId = 'muscles_plot', - height = "500px", width = "500px")), - tabPanel(title = "Workout History", - plotOutput(outputId = "history_plot"))))) -)) diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E b/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E deleted file mode 100644 index 912a68a..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E +++ /dev/null @@ -1,26 +0,0 @@ -{ - "id": "BA0BC75E", - "path": "~/Documents/projects/liftboard/server.R", - "project_path": "server.R", - "type": "r_source", - "hash": "3533336264", - "contents": "", - "dirty": false, - "created": 1618861937261.0, - "source_on_save": false, - "relative_order": 2, - "properties": { - "source_window_id": "", - "Source": "Source", - "cursorPosition": "8,0", - "scrollLine": "0" - }, - "folds": "", - "lastKnownWriteTime": 1626331698, - "encoding": "UTF-8", - "collab_server": "", - "source_window": "", - "last_content_update": 1626331698463, - "read_only": false, - "read_only_alternatives": [] -} \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E-contents b/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E-contents deleted file mode 100644 index 79b14df..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E-contents +++ /dev/null @@ -1,95 +0,0 @@ -# -# This is the server logic of a Shiny web application. You can run the -# application by clicking 'Run App' above. -# -# Find out more about building applications with Shiny here: -# -# http://shiny.rstudio.com/ -# - -# Define server logic required to draw a histogram -shinyServer(function(input, output) { - - selectedData <- reactive({ - filter(lifts, Category == input$muscles)}) - - setsData <- reactive({ - selectedData() %>% - group_by(Exercise) %>% - count(name='Sets')}) - - output$exercises_plot <- renderPlot({ - if (input$metric == 'Sets') { - ggplot(data = setsData()) + - geom_bar(mapping = aes(x=Exercise, weight=Sets), - fill = '#00aaaa', - color = 'black') + - ylab('Sets') - } else { - ggplot(data = selectedData()) + - geom_bar(mapping = aes(x=Exercise, weight=!!sym(input$metric)), - fill = '#00aaaa', - color = 'black') + - ylab(input$metric) - }}) - - sumBreakdown <- reactive({ - if(input$metric == 'Sets') { - lifts %>% - group_by(Category) %>% - count(name = 'Sets') %>% - pivot_wider(names_from = Category, values_from = Sets) - } else { - lifts %>% - group_by(Category) %>% - summarize(Metric = sum(!!sym(input$metric))) %>% - pivot_wider(names_from = Category, values_from = Metric) - }}) - - step_size <- reactive({ - if (input$metric == 'Sets') { - 8 - } else if (input$metric == 'Reps') { - 35 - } else { - 1000 - }}) - - maxval <- reactive({ - step_size()*((max(sumBreakdown()) %/% step_size()) + 1)}) - - radarData <- reactive({ - rbind(rep(maxval(),6), rep(0, 6), sumBreakdown())}) - - output$muscles_plot <- renderPlot({ - radarchart(radarData(), axistype = 1, - pcol = rgb(0.2, 0.5, 0.5, 1), - pfcol = rgb(0.2, 0.5, 0.5, 0.5), - plwd = 2, - cglcol = 'grey', - cglty = 1, - axislabcol = 'black', - caxislabels = seq(0,maxval(),step_size()), - cglwd = 1, - vlcex = 1)}) - - historyData <- reactive({ - if (input$metric == 'Sets') { - lifts %>% - filter(Category == input$muscles) %>% - group_by(Date) %>% - count(name = 'Sets') - } else { - lifts %>% - filter(Category == input$muscles) %>% - group_by(Date) %>% - summarize(Metric = sum(!!sym(input$metric)))}}) - - output$history_plot <- renderPlot({ - ggplot(data = historyData(), mapping = aes(x=Date, y=!!sym(input$metric))) + - geom_line() + - geom_point() - }) -}) - -## todo: figure out how to pass a variable into geom_bar.... \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/F11D91F6-contents b/.Rproj.user/688FCC69/sources/s-FA01BD99/F11D91F6-contents deleted file mode 100644 index e69de29..0000000 diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 b/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 deleted file mode 100644 index 11cf3d4..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 +++ /dev/null @@ -1,27 +0,0 @@ -{ - "id": "FEEDDA97", - "path": "~/Documents/projects/liftboard/global.R", - "project_path": "global.R", - "type": "r_source", - "hash": "0", - "contents": "", - "dirty": false, - "created": 1618888022407.0, - "source_on_save": false, - "relative_order": 3, - "properties": { - "tempName": "Untitled1", - "source_window_id": "", - "Source": "Source", - "cursorPosition": "12,56", - "scrollLine": "0" - }, - "folds": "", - "lastKnownWriteTime": 1620281651, - "encoding": "UTF-8", - "collab_server": "", - "source_window": "", - "last_content_update": 1620281651378, - "read_only": false, - "read_only_alternatives": [] -} \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97-contents b/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97-contents deleted file mode 100644 index 83e39f0..0000000 --- a/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97-contents +++ /dev/null @@ -1,13 +0,0 @@ -library(shiny) -library(ggplot2) -library(dplyr) -library(tidyr) -library(readr) -library(fmsb) - -lifts <- read_csv('data/lifts.csv') -lifts <- rename(lifts, Weight = `Weight (lbs)`) -muscles <- c('Back', 'Biceps', 'Chest', 'Legs', 'Shoulders', 'Triceps') -lifts <- lifts %>% - filter(Category %in% muscles) %>% - select(Date, Exercise, Category, Weight, Reps) \ No newline at end of file diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/lock_file b/.Rproj.user/688FCC69/sources/s-FA01BD99/lock_file deleted file mode 100644 index e69de29..0000000 diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths index 3b76b96..0db4e94 100644 --- a/.Rproj.user/shared/notebooks/paths +++ b/.Rproj.user/shared/notebooks/paths @@ -1,4 +1,5 @@ /Users/adu/Documents/projects/liftboard/data/lifts.csv="C078BA41" /Users/adu/Documents/projects/liftboard/global.R="DE15BE1B" /Users/adu/Documents/projects/liftboard/renv/.gitignore="3CFF03A3" -/Users/adu/Documents/projects/liftboard/testy.R="5D9D56E0" +/Users/adu/Documents/projects/liftboard/server.R="23D01622" +/Users/adu/Documents/projects/liftboard/ui.R="ACFB268D" diff --git a/.gitignore b/.gitignore index e43b0f9..3ecd7f3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +.Rproj.user diff --git a/server.R b/server.R index 79b14df..6dcacbd 100644 --- a/server.R +++ b/server.R @@ -83,7 +83,9 @@ shinyServer(function(input, output) { lifts %>% filter(Category == input$muscles) %>% group_by(Date) %>% - summarize(Metric = sum(!!sym(input$metric)))}}) + summarize(!!sym(input$metric) := sum(!!sym(input$metric))) + } + }) output$history_plot <- renderPlot({ ggplot(data = historyData(), mapping = aes(x=Date, y=!!sym(input$metric))) + -- 2.43.0