From fb29fc7d9c946ede8dade2c3fc1e9eb601f3178b Mon Sep 17 00:00:00 2001 From: ibidyouadu Date: Thu, 15 Jul 2021 02:57:30 -0400 Subject: [PATCH] initial commit --- .DS_Store | Bin 0 -> 6148 bytes .RData | Bin 0 -> 2595 bytes .Rhistory | 103 +++ .Rprofile | 1 + .../688FCC69/pcs/debug-breakpoints.pper | 5 + .Rproj.user/688FCC69/pcs/files-pane.pper | 9 + .Rproj.user/688FCC69/pcs/source-pane.pper | 3 + .../688FCC69/pcs/windowlayoutstate.pper | 14 + .Rproj.user/688FCC69/pcs/workbench-pane.pper | 5 + .Rproj.user/688FCC69/persistent-state | 8 + .Rproj.user/688FCC69/rmd-outputs | 5 + .Rproj.user/688FCC69/saved_source_markers | 1 + .Rproj.user/688FCC69/sources/prop/174853EF | 4 + .Rproj.user/688FCC69/sources/prop/41F698B5 | 7 + .Rproj.user/688FCC69/sources/prop/6815E065 | 6 + .Rproj.user/688FCC69/sources/prop/AFE2E5A0 | 4 + .Rproj.user/688FCC69/sources/prop/C3524A44 | 7 + .Rproj.user/688FCC69/sources/prop/D4824927 | 6 + .Rproj.user/688FCC69/sources/prop/INDEX | 6 + .../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 .../shared/notebooks/patch-chunk-names | 0 .Rproj.user/shared/notebooks/paths | 4 + data/.DS_Store | Bin 0 -> 6148 bytes data/lifts.csv | 355 ++++++++++ global.R | 13 + liftboard.Rproj | 13 + renv.lock | 566 +++++++++++++++ renv/.gitignore | 5 + renv/activate.R | 654 ++++++++++++++++++ renv/settings.dcf | 8 + .../shinyapps.io/ibidyouadu/liftboard.dcf | 11 + server.R | 95 +++ ui.R | 47 ++ 42 files changed, 2215 insertions(+) create mode 100644 .DS_Store create mode 100644 .RData create mode 100644 .Rhistory create mode 100644 .Rprofile create mode 100644 .Rproj.user/688FCC69/pcs/debug-breakpoints.pper create mode 100644 .Rproj.user/688FCC69/pcs/files-pane.pper create mode 100644 .Rproj.user/688FCC69/pcs/source-pane.pper create mode 100644 .Rproj.user/688FCC69/pcs/windowlayoutstate.pper create mode 100644 .Rproj.user/688FCC69/pcs/workbench-pane.pper create mode 100644 .Rproj.user/688FCC69/persistent-state create mode 100644 .Rproj.user/688FCC69/rmd-outputs create mode 100644 .Rproj.user/688FCC69/saved_source_markers create mode 100644 .Rproj.user/688FCC69/sources/prop/174853EF create mode 100644 .Rproj.user/688FCC69/sources/prop/41F698B5 create mode 100644 .Rproj.user/688FCC69/sources/prop/6815E065 create mode 100644 .Rproj.user/688FCC69/sources/prop/AFE2E5A0 create mode 100644 .Rproj.user/688FCC69/sources/prop/C3524A44 create mode 100644 .Rproj.user/688FCC69/sources/prop/D4824927 create mode 100644 .Rproj.user/688FCC69/sources/prop/INDEX create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/5C556F75-contents create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/63C95A32-contents create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/A690A505-contents create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E-contents create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/F11D91F6-contents create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97-contents create mode 100644 .Rproj.user/688FCC69/sources/s-FA01BD99/lock_file create mode 100644 .Rproj.user/shared/notebooks/patch-chunk-names create mode 100644 .Rproj.user/shared/notebooks/paths create mode 100644 data/.DS_Store create mode 100644 data/lifts.csv create mode 100644 global.R create mode 100644 liftboard.Rproj create mode 100644 renv.lock create mode 100644 renv/.gitignore create mode 100644 renv/activate.R create mode 100644 renv/settings.dcf create mode 100644 rsconnect/shinyapps.io/ibidyouadu/liftboard.dcf create mode 100644 server.R create mode 100644 ui.R diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..d7a0739c9986550f0cd1d9cff18b9d972ec35112 GIT binary patch literal 6148 zcmeHKPfy!06t_!9lcGTmlgiPT-Fj#N!FE8(N;z;t%CsFe)Fw?uBc*ZGq*Pn!lrOLk z0AGg_cO<^f-m~4RRR^~sHoYg=zvuVIc7BQMJjNJrjKVr&4r9!MhFGwn`-`9-+lmy7 zr3A=vj$oV)f>;JHzF&zZ!)s&!-(8V~%x4+%7vEnnh@&*C)gF0aqxfdCWLf2M`EB{a z>&dZ~`PnFK_``2FI`^|)VD!&Y#&g{dzC_(|%XxPqlgy8j?ocI1VHZNae~pq*jvI26 zgsGax(+W!z7l;CCoS5{K6JUB?gEAVqlF7m{Z5vTH_itH8DU8{F@Bm`5>Snx(0KN>ga$@ zl>mT6Fe?EaYYEH|23>=>M(}`eoeHQ^xhXNYP6xX%ajwB!qfTes6d&BI%uR*D)#@<6 zP~nWb8mT7+h=FAWHuTWJ`~URm`hPizM#KOy@Lw^&i%qZDfJZWS>&nC7T`Qoqp`l=0 nu5q3Min@v+7O&!6XiC5?Pyuue<{H5QLO%kE2I`1`7iHiN@eFPf literal 0 HcmV?d00001 diff --git a/.RData b/.RData new file mode 100644 index 0000000000000000000000000000000000000000..f676bcbeafb1e5fd86e7bf9074e0b856ccf38364 GIT binary patch literal 2595 zcmV+;3f%P{iwFP!000000|5*Q^Yv0hSThP(3IG5A0{{d70{{aB000001yxi=EjR!G z1Ofm60096500{s901PftVQyq^Z7y?VWn=&V01W^D0&)NVD5C%X01BLWXfhK=vb zIRN76JVVb5ui?(ie^6m5(XP`rUs+~6m1_#5eA<1mb({o=`Jdc4+x1^NI*cPquVR7W zPd&jxC$~f8WL`HvS(tr-{QD_-*qLSI2`G_9uhw4i{87t_7XzZTo{|@l{3IS-BIn8J z*F7y!XS5Jl>>5Ky*Jb4(ss9N@WQO*;2oOJXnzM(^*->6Jxd6n_d)|<5NGU)%f7|Y# zJnBF?DvaP5)z4&bX@$5;ay->_Clc|NEDcqYXGh=oMJ_!V^oZ?#L5nqlxoOiNb2upk zUFItIse$os-4pbS8p2`c1$1aYwReI$zHL7Z5dbAwVR4#D`=bioYVz}6DnuGj^#=ka?A>_S zDby4tZ2DME)I|pZgr6_21}464!mvbQ&r^QNdU1xrhoF3!FFxA3wn^J%68n$D(#llr zbS$w+EH79r#O0${Eu1=c&+?+Oifz5@PpAE=5zYgWS11@)9V`FJFG-Nt)L1^CaRwSn zEaAn|%yU!}IN~S}pj3dBWmoscl}-MnsN~vGl*(j|88zg@&yUg^43--hgg|AwRRfpt zc_H@GvJfxRIquE&4Vfcf`YR6UOB$)(G2C(R$KR_fKefyeiA>0bzoH$9*8T3Vm-loZ zu^!_M+t^Try*tcfTG`@~HfVfg=azfr^AZ0;oWmwy)Y6Lpp=3$OG^e#tS^ZdK^Yms2 z4BAHSo+YYgb3a{|z{ZRf-B4H2rE|GkuaSv30l?1m1D-L<9cfSSWt;yX2&xC3cFb!k z*N>tXlf@lt_k7wP2hyh9XH5vuHV3puh3@q#5Xg@&-^=M(x+x~<2zY81g{D;f&%uAN zR8ylJdjfez9yH_18@GJV(r|qfS|pt9NH~ulNg5xvG|;DU={#q2GnDt9mx4hdJHUdT zmOT7c(U7RW_#%?%{Rjmvh>ZD*KOFc?Jdz{V?SOxP@DzsOXDHtQmO9_a>ChK_fouxA ztF-fAQWB3sN8tLa>CE;}h~Q3B)FPk++bETI`V1W*Gd$BGH}dT*!tk9ydPKS!W?1Z1 zhdOT!m+(8ReHlF z&9GD;L%i}GxKzg$FT&8js31!cK)gUbI#Ayg7vdUg4ro0y?o2Cn82onm|MJEAH2`o~ zD|AW>C*BQ*!VO7I30@%p~7_A2?i2K$_w27SJgww7iP9+LTgA>Vov>5Ws`WMLdy_*pO=1 zz9M|bSBcuUhQSy^uKe4SeRrkrb}yJwm^lLjbkTYrOjYV^D(nH6kCz zNl3*^%nbe63|uXTbkb0&GyoI7hg7&JN$9B?+xo<#O3?lCB`jHdJoHMu1CmL)Okj=` z*$gi*>fnaJm14PW7N}6-E=bY;( zM9yy%ejGfL<&CmCWA|tqhXDOs?Oq$qmMcD~87-(bWt!q{GgvN{>cM9EU2{5|ev~yh zdm<)3mNyYSQvuf)+6E~Zs6_7i>28@&Z1B@Nf<+ zMj6cNmic13e^V4+oyIhVa@|=8iVN;Je&Y z1f8J{_)5HAs%TLvhEbLn{X+ovEJXL>Uh*Q>#>eJ|Opz9+0u~efFm$l3Qw22)nNRJ& zt4ItNYUZfM920mFgLM*#(^5CiW1z)K28nJh^1H7DsSIYkgqr>cPsa2$&8UN=UV3=K&ZMH5L#zRA{3x(Xoup%8lBM^C04!QYw z<7?bXI$Vm|_ll1ahkv~NI?34uQ(hQy=nO^#_uc1Tg6BG6+YrUJ@-C4>2-~jdwY{<^ zV=9_!E6Cx>sPX2jhGRdg5@ey<5t8!79%nha{xR>W!*&x0IFxo*2BkaQBd?w2P-rt& zR7TOkLGxQ`y;a86XEHNn>i}C>FX>lMGF$XROst8d61oRu_-}9?aC2L~pT 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 new file mode 100644 index 0000000..2129631 --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/63C95A32-contents @@ -0,0 +1,5 @@ +library/ +local/ +lock/ +python/ +staging/ diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 b/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 new file mode 100644 index 0000000..e18e44c --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505 @@ -0,0 +1,26 @@ +{ + "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 new file mode 100644 index 0000000..3d4f7ae --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/A690A505-contents @@ -0,0 +1,47 @@ +# +# 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 new file mode 100644 index 0000000..912a68a --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E @@ -0,0 +1,26 @@ +{ + "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 new file mode 100644 index 0000000..79b14df --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/BA0BC75E-contents @@ -0,0 +1,95 @@ +# +# 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 new file mode 100644 index 0000000..e69de29 diff --git a/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 b/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 new file mode 100644 index 0000000..11cf3d4 --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97 @@ -0,0 +1,27 @@ +{ + "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 new file mode 100644 index 0000000..83e39f0 --- /dev/null +++ b/.Rproj.user/688FCC69/sources/s-FA01BD99/FEEDDA97-contents @@ -0,0 +1,13 @@ +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 new file mode 100644 index 0000000..e69de29 diff --git a/.Rproj.user/shared/notebooks/patch-chunk-names b/.Rproj.user/shared/notebooks/patch-chunk-names new file mode 100644 index 0000000..e69de29 diff --git a/.Rproj.user/shared/notebooks/paths b/.Rproj.user/shared/notebooks/paths new file mode 100644 index 0000000..3b76b96 --- /dev/null +++ b/.Rproj.user/shared/notebooks/paths @@ -0,0 +1,4 @@ +/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" diff --git a/data/.DS_Store b/data/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0% + filter(Category %in% muscles) %>% + select(Date, Exercise, Category, Weight, Reps) \ No newline at end of file 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/renv.lock b/renv.lock new file mode 100644 index 0000000..190ea7f --- /dev/null +++ b/renv.lock @@ -0,0 +1,566 @@ +{ + "R": { + "Version": "4.0.3", + "Repositories": [ + { + "Name": "CRAN", + "URL": "https://cran.rstudio.com" + } + ] + }, + "Packages": { + "BH": { + "Package": "BH", + "Version": "1.75.0-0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e4c04affc2cac20c8fec18385cd14691" + }, + "MASS": { + "Package": "MASS", + "Version": "7.3-53", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d1bc1c8e9c0ace57ec9ffea01021d45f" + }, + "Matrix": { + "Package": "Matrix", + "Version": "1.2-18", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "08588806cba69f04797dab50627428ed" + }, + "R6": { + "Package": "R6", + "Version": "2.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b203113193e70978a696b2809525649d" + }, + "RColorBrewer": { + "Package": "RColorBrewer", + "Version": "1.1-2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e031418365a7f7a766181ab5a41a5716" + }, + "Rcpp": { + "Package": "Rcpp", + "Version": "1.0.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "dbb5e436998a7eba5a9d682060533338" + }, + "assertthat": { + "Package": "assertthat", + "Version": "0.2.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "50c838a310445e954bc13f26f26a6ecf" + }, + "base64enc": { + "Package": "base64enc", + "Version": "0.1-3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "543776ae6848fde2f48ff3816d0628bc" + }, + "brio": { + "Package": "brio", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "36758510e65a457efeefa50e1e7f0576" + }, + "bslib": { + "Package": "bslib", + "Version": "0.2.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4830a372b241d78ed6f53731ee3023ac" + }, + "cachem": { + "Package": "cachem", + "Version": "1.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2703a46dcabfb902f10060b2bca9f708" + }, + "callr": { + "Package": "callr", + "Version": "3.5.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b7d7f1e926dfcd57c74ce93f5c048e80" + }, + "cli": { + "Package": "cli", + "Version": "2.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "26fb4f0871c8e5b84d77f6dc22f2ee0a" + }, + "clipr": { + "Package": "clipr", + "Version": "0.7.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaa97ac99cc2daf04e77eecc7b781d7" + }, + "colorspace": { + "Package": "colorspace", + "Version": "2.0-0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "abea3384649ef37f60ef51ce002f3547" + }, + "commonmark": { + "Package": "commonmark", + "Version": "1.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "0f22be39ec1d141fd03683c06f3a6e67" + }, + "cpp11": { + "Package": "cpp11", + "Version": "0.2.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "f08909ebdad90b19d8d3930da4220564" + }, + "crayon": { + "Package": "crayon", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fcff9126a4928a96c94e3df85b024899" + }, + "desc": { + "Package": "desc", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6c8fe8fa26a23b79949375d372c7b395" + }, + "diffobj": { + "Package": "diffobj", + "Version": "0.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "55fae7ec1418d2a47bd552571673d1af" + }, + "digest": { + "Package": "digest", + "Version": "0.6.27", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a0cbe758a531d054b537d16dff4d58a1" + }, + "dplyr": { + "Package": "dplyr", + "Version": "1.0.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "01c82e3b053eb7660a8ace8d932265b8" + }, + "ellipsis": { + "Package": "ellipsis", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fd2844b3a43ae2d27e70ece2df1b4e2a" + }, + "evaluate": { + "Package": "evaluate", + "Version": "0.14", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ec8ca05cffcc70569eaaad8469d2a3a7" + }, + "fansi": { + "Package": "fansi", + "Version": "0.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fea074fb67fe4c25d47ad09087da847d" + }, + "farver": { + "Package": "farver", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "dad6793a5a1f73c8e91f1a1e3e834b05" + }, + "fastmap": { + "Package": "fastmap", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "77bd60a6157420d4ffa93b27cf6a58b8" + }, + "fmsb": { + "Package": "fmsb", + "Version": "0.7.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a3c0f930bb46c1bb7e7077ed3689f921" + }, + "fs": { + "Package": "fs", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "44594a07a42e5f91fac9f93fda6d0109" + }, + "generics": { + "Package": "generics", + "Version": "0.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4d243a9c10b00589889fe32314ffd902" + }, + "ggplot2": { + "Package": "ggplot2", + "Version": "3.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3eb6477d01eb5bbdc03f7d5f70f2733e" + }, + "glue": { + "Package": "glue", + "Version": "1.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6efd734b14c6471cfe443345f3e35e29" + }, + "gtable": { + "Package": "gtable", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ac5c6baf7822ce8732b343f14c072c4d" + }, + "hms": { + "Package": "hms", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "bf552cdd96f5969873afdac7311c7d0d" + }, + "htmltools": { + "Package": "htmltools", + "Version": "0.5.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "af2c2531e55df5cf230c4b5444fc973c" + }, + "httpuv": { + "Package": "httpuv", + "Version": "1.5.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b9d5d39be2150cf86538b8488334b8f8" + }, + "isoband": { + "Package": "isoband", + "Version": "0.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "53647fb507373700028b2ce6cd30751a" + }, + "jquerylib": { + "Package": "jquerylib", + "Version": "0.1.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5ff50b36f7f0832f8421745af333e73c" + }, + "jsonlite": { + "Package": "jsonlite", + "Version": "1.7.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "98138e0994d41508c7a6b84a0600cfcb" + }, + "labeling": { + "Package": "labeling", + "Version": "0.4.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3d5108641f47470611a32d0bdf357a72" + }, + "later": { + "Package": "later", + "Version": "1.1.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "d0a62b247165aabf397fded504660d8a" + }, + "lattice": { + "Package": "lattice", + "Version": "0.20-41", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "fbd9285028b0263d76d18c95ae51a53d" + }, + "lifecycle": { + "Package": "lifecycle", + "Version": "0.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "361811f31f71f8a617a9a68bf63f1f42" + }, + "magrittr": { + "Package": "magrittr", + "Version": "2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "41287f1ac7d28a92f0a286ed507928d3" + }, + "mgcv": { + "Package": "mgcv", + "Version": "1.8-33", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "eb7b6439bc6d812eed2cddba5edc6be3" + }, + "mime": { + "Package": "mime", + "Version": "0.9", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "e87a35ec73b157552814869f45a63aa3" + }, + "munsell": { + "Package": "munsell", + "Version": "0.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6dfe8bf774944bd5595785e3229d8771" + }, + "nlme": { + "Package": "nlme", + "Version": "3.1-149", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "7c24ab3a1e3afe50388eb2d893aab255" + }, + "pillar": { + "Package": "pillar", + "Version": "1.4.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3b3dd89b2ee115a8b54e93a34cd546b4" + }, + "pkgbuild": { + "Package": "pkgbuild", + "Version": "1.2.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "725fcc30222d4d11ec68efb8ff11a9af" + }, + "pkgconfig": { + "Package": "pkgconfig", + "Version": "2.0.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "01f28d4278f15c76cddbea05899c5d6f" + }, + "pkgload": { + "Package": "pkgload", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b6b150cd4709e0c0c9b5d51ac4376282" + }, + "praise": { + "Package": "praise", + "Version": "1.0.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "a555924add98c99d2f411e37e7d25e9f" + }, + "prettyunits": { + "Package": "prettyunits", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "95ef9167b75dde9d2ccc3c7528393e7e" + }, + "processx": { + "Package": "processx", + "Version": "3.4.5", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "22aab6098cb14edd0a5973a8438b569b" + }, + "promises": { + "Package": "promises", + "Version": "1.2.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4ab2c43adb4d4699cf3690acd378d75d" + }, + "ps": { + "Package": "ps", + "Version": "1.5.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ebaed51a03411fd5cfc1e12d9079b353" + }, + "purrr": { + "Package": "purrr", + "Version": "0.3.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "97def703420c8ab10d8f0e6c72101e02" + }, + "rappdirs": { + "Package": "rappdirs", + "Version": "0.3.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5e3c5dc0b071b21fa128676560dbe94d" + }, + "readr": { + "Package": "readr", + "Version": "1.4.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "2639976851f71f330264a9c9c3d43a61" + }, + "rematch2": { + "Package": "rematch2", + "Version": "2.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "76c9e04c712a05848ae7a23d2f170a40" + }, + "renv": { + "Package": "renv", + "Version": "0.13.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "079cb1f03ff972b30401ed05623cbe92" + }, + "rlang": { + "Package": "rlang", + "Version": "0.4.10", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "599df23c40a4fce9c7b4764f28c37857" + }, + "rprojroot": { + "Package": "rprojroot", + "Version": "2.0.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "249d8cd1e74a8f6a26194a91b47f21d1" + }, + "rstudioapi": { + "Package": "rstudioapi", + "Version": "0.13", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "06c85365a03fdaf699966cc1d3cf53ea" + }, + "sass": { + "Package": "sass", + "Version": "0.3.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "3ef1adfe46b7b144b970d74ce33ab0d6" + }, + "scales": { + "Package": "scales", + "Version": "1.1.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6f76f71042411426ec8df6c54f34e6dd" + }, + "shiny": { + "Package": "shiny", + "Version": "1.6.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6e3b6ae7fe02b5859e4bb277f218b8ae" + }, + "sourcetools": { + "Package": "sourcetools", + "Version": "0.1.7", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "947e4e02a79effa5d512473e10f41797" + }, + "testthat": { + "Package": "testthat", + "Version": "3.0.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "17826764cb92d8b5aae6619896e5a161" + }, + "tibble": { + "Package": "tibble", + "Version": "3.0.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "9c6c10e594f32096ede0c7d373ccbddd" + }, + "tidyr": { + "Package": "tidyr", + "Version": "1.1.2", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "c40b2d5824d829190f4b825f4496dfae" + }, + "tidyselect": { + "Package": "tidyselect", + "Version": "1.1.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "6ea435c354e8448819627cf686f66e0a" + }, + "utf8": { + "Package": "utf8", + "Version": "1.1.4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "4a5081acfb7b81a572e4384a7aaf2af1" + }, + "vctrs": { + "Package": "vctrs", + "Version": "0.3.6", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "5cf1957f93076c19fdc81d01409d240b" + }, + "viridisLite": { + "Package": "viridisLite", + "Version": "0.3.0", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "ce4f6271baa94776db692f1cb2055bee" + }, + "waldo": { + "Package": "waldo", + "Version": "0.2.3", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "181d1a31b1ba2009ef20926f2ee0570c" + }, + "withr": { + "Package": "withr", + "Version": "2.4.1", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "caf4781c674ffa549a4676d2d77b13cc" + }, + "xtable": { + "Package": "xtable", + "Version": "1.8-4", + "Source": "Repository", + "Repository": "CRAN", + "Hash": "b8acdf8af494d9ec19ccb2481a9b11c2" + } + } +} diff --git a/renv/.gitignore b/renv/.gitignore new file mode 100644 index 0000000..2129631 --- /dev/null +++ b/renv/.gitignore @@ -0,0 +1,5 @@ +library/ +local/ +lock/ +python/ +staging/ diff --git a/renv/activate.R b/renv/activate.R new file mode 100644 index 0000000..b852628 --- /dev/null +++ b/renv/activate.R @@ -0,0 +1,654 @@ + +local({ + + # the requested version of renv + version <- "0.13.2" + + # the project directory + project <- getwd() + + # avoid recursion + if (!is.na(Sys.getenv("RENV_R_INITIALIZING", unset = NA))) + return(invisible(TRUE)) + + # signal that we're loading renv during R startup + Sys.setenv("RENV_R_INITIALIZING" = "true") + on.exit(Sys.unsetenv("RENV_R_INITIALIZING"), add = TRUE) + + # signal that we've consented to use renv + options(renv.consent = TRUE) + + # load the 'utils' package eagerly -- this ensures that renv shims, which + # mask 'utils' packages, will come first on the search path + library(utils, lib.loc = .Library) + + # check to see if renv has already been loaded + if ("renv" %in% loadedNamespaces()) { + + # if renv has already been loaded, and it's the requested version of renv, + # nothing to do + spec <- .getNamespaceInfo(.getNamespace("renv"), "spec") + if (identical(spec[["version"]], version)) + return(invisible(TRUE)) + + # otherwise, unload and attempt to load the correct version of renv + unloadNamespace("renv") + + } + + # load bootstrap tools + bootstrap <- function(version, library) { + + # attempt to download renv + tarball <- tryCatch(renv_bootstrap_download(version), error = identity) + if (inherits(tarball, "error")) + stop("failed to download renv ", version) + + # now attempt to install + status <- tryCatch(renv_bootstrap_install(version, tarball, library), error = identity) + if (inherits(status, "error")) + stop("failed to install renv ", version) + + } + + renv_bootstrap_tests_running <- function() { + getOption("renv.tests.running", default = FALSE) + } + + renv_bootstrap_repos <- function() { + + # check for repos override + repos <- Sys.getenv("RENV_CONFIG_REPOS_OVERRIDE", unset = NA) + if (!is.na(repos)) + return(repos) + + # if we're testing, re-use the test repositories + if (renv_bootstrap_tests_running()) + return(getOption("renv.tests.repos")) + + # retrieve current repos + repos <- getOption("repos") + + # ensure @CRAN@ entries are resolved + repos[repos == "@CRAN@"] <- getOption( + "renv.repos.cran", + "https://cloud.r-project.org" + ) + + # add in renv.bootstrap.repos if set + default <- c(FALLBACK = "https://cloud.r-project.org") + extra <- getOption("renv.bootstrap.repos", default = default) + repos <- c(repos, extra) + + # remove duplicates that might've snuck in + dupes <- duplicated(repos) | duplicated(names(repos)) + repos[!dupes] + + } + + renv_bootstrap_download <- function(version) { + + # if the renv version number has 4 components, assume it must + # be retrieved via github + nv <- numeric_version(version) + components <- unclass(nv)[[1]] + + methods <- if (length(components) == 4L) { + list( + renv_bootstrap_download_github + ) + } else { + list( + renv_bootstrap_download_cran_latest, + renv_bootstrap_download_cran_archive + ) + } + + for (method in methods) { + path <- tryCatch(method(version), error = identity) + if (is.character(path) && file.exists(path)) + return(path) + } + + stop("failed to download renv ", version) + + } + + renv_bootstrap_download_impl <- function(url, destfile) { + + mode <- "wb" + + # https://bugs.r-project.org/bugzilla/show_bug.cgi?id=17715 + fixup <- + Sys.info()[["sysname"]] == "Windows" && + substring(url, 1L, 5L) == "file:" + + if (fixup) + mode <- "w+b" + + utils::download.file( + url = url, + destfile = destfile, + mode = mode, + quiet = TRUE + ) + + } + + renv_bootstrap_download_cran_latest <- function(version) { + + spec <- renv_bootstrap_download_cran_latest_find(version) + + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + + type <- spec$type + repos <- spec$repos + + info <- tryCatch( + utils::download.packages( + pkgs = "renv", + destdir = tempdir(), + repos = repos, + type = type, + quiet = TRUE + ), + condition = identity + ) + + if (inherits(info, "condition")) { + message("FAILED") + return(FALSE) + } + + # report success and return + message("OK (downloaded ", type, ")") + info[1, 2] + + } + + renv_bootstrap_download_cran_latest_find <- function(version) { + + # check whether binaries are supported on this system + binary <- + getOption("renv.bootstrap.binary", default = TRUE) && + !identical(.Platform$pkgType, "source") && + !identical(getOption("pkgType"), "source") && + Sys.info()[["sysname"]] %in% c("Darwin", "Windows") + + types <- c(if (binary) "binary", "source") + + # iterate over types + repositories + for (type in types) { + for (repos in renv_bootstrap_repos()) { + + # retrieve package database + db <- tryCatch( + as.data.frame( + utils::available.packages(type = type, repos = repos), + stringsAsFactors = FALSE + ), + error = identity + ) + + if (inherits(db, "error")) + next + + # check for compatible entry + entry <- db[db$Package %in% "renv" & db$Version %in% version, ] + if (nrow(entry) == 0) + next + + # found it; return spec to caller + spec <- list(entry = entry, type = type, repos = repos) + return(spec) + + } + } + + # if we got here, we failed to find renv + fmt <- "renv %s is not available from your declared package repositories" + stop(sprintf(fmt, version)) + + } + + renv_bootstrap_download_cran_archive <- function(version) { + + name <- sprintf("renv_%s.tar.gz", version) + repos <- renv_bootstrap_repos() + urls <- file.path(repos, "src/contrib/Archive/renv", name) + destfile <- file.path(tempdir(), name) + + message("* Downloading renv ", version, " ... ", appendLF = FALSE) + + for (url in urls) { + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (identical(status, 0L)) { + message("OK") + return(destfile) + } + + } + + message("FAILED") + return(FALSE) + + } + + renv_bootstrap_download_github <- function(version) { + + enabled <- Sys.getenv("RENV_BOOTSTRAP_FROM_GITHUB", unset = "TRUE") + if (!identical(enabled, "TRUE")) + return(FALSE) + + # prepare download options + pat <- Sys.getenv("GITHUB_PAT") + if (nzchar(Sys.which("curl")) && nzchar(pat)) { + fmt <- "--location --fail --header \"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "curl", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } else if (nzchar(Sys.which("wget")) && nzchar(pat)) { + fmt <- "--header=\"Authorization: token %s\"" + extra <- sprintf(fmt, pat) + saved <- options("download.file.method", "download.file.extra") + options(download.file.method = "wget", download.file.extra = extra) + on.exit(do.call(base::options, saved), add = TRUE) + } + + message("* Downloading renv ", version, " from GitHub ... ", appendLF = FALSE) + + url <- file.path("https://api.github.com/repos/rstudio/renv/tarball", version) + name <- sprintf("renv_%s.tar.gz", version) + destfile <- file.path(tempdir(), name) + + status <- tryCatch( + renv_bootstrap_download_impl(url, destfile), + condition = identity + ) + + if (!identical(status, 0L)) { + message("FAILED") + return(FALSE) + } + + message("OK") + return(destfile) + + } + + renv_bootstrap_install <- function(version, tarball, library) { + + # attempt to install it into project library + message("* Installing renv ", version, " ... ", appendLF = FALSE) + dir.create(library, showWarnings = FALSE, recursive = TRUE) + + # invoke using system2 so we can capture and report output + bin <- R.home("bin") + exe <- if (Sys.info()[["sysname"]] == "Windows") "R.exe" else "R" + r <- file.path(bin, exe) + args <- c("--vanilla", "CMD", "INSTALL", "-l", shQuote(library), shQuote(tarball)) + output <- system2(r, args, stdout = TRUE, stderr = TRUE) + message("Done!") + + # check for successful install + status <- attr(output, "status") + if (is.numeric(status) && !identical(status, 0L)) { + header <- "Error installing renv:" + lines <- paste(rep.int("=", nchar(header)), collapse = "") + text <- c(header, lines, output) + writeLines(text, con = stderr()) + } + + status + + } + + renv_bootstrap_platform_prefix <- function() { + + # construct version prefix + version <- paste(R.version$major, R.version$minor, sep = ".") + prefix <- paste("R", numeric_version(version)[1, 1:2], sep = "-") + + # include SVN revision for development versions of R + # (to avoid sharing platform-specific artefacts with released versions of R) + devel <- + identical(R.version[["status"]], "Under development (unstable)") || + identical(R.version[["nickname"]], "Unsuffered Consequences") + + if (devel) + prefix <- paste(prefix, R.version[["svn rev"]], sep = "-r") + + # build list of path components + components <- c(prefix, R.version$platform) + + # include prefix if provided by user + prefix <- renv_bootstrap_platform_prefix_impl() + if (!is.na(prefix) && nzchar(prefix)) + components <- c(prefix, components) + + # build prefix + paste(components, collapse = "/") + + } + + renv_bootstrap_platform_prefix_impl <- function() { + + # if an explicit prefix has been supplied, use it + prefix <- Sys.getenv("RENV_PATHS_PREFIX", unset = NA) + if (!is.na(prefix)) + return(prefix) + + # if the user has requested an automatic prefix, generate it + auto <- Sys.getenv("RENV_PATHS_PREFIX_AUTO", unset = NA) + if (auto %in% c("TRUE", "True", "true", "1")) + return(renv_bootstrap_platform_prefix_auto()) + + # empty string on failure + "" + + } + + renv_bootstrap_platform_prefix_auto <- function() { + + prefix <- tryCatch(renv_bootstrap_platform_os(), error = identity) + if (inherits(prefix, "error") || prefix %in% "unknown") { + + msg <- paste( + "failed to infer current operating system", + "please file a bug report at https://github.com/rstudio/renv/issues", + sep = "; " + ) + + warning(msg) + + } + + prefix + + } + + renv_bootstrap_platform_os <- function() { + + sysinfo <- Sys.info() + sysname <- sysinfo[["sysname"]] + + # handle Windows + macOS up front + if (sysname == "Windows") + return("windows") + else if (sysname == "Darwin") + return("macos") + + # check for os-release files + for (file in c("/etc/os-release", "/usr/lib/os-release")) + if (file.exists(file)) + return(renv_bootstrap_platform_os_via_os_release(file, sysinfo)) + + # check for redhat-release files + if (file.exists("/etc/redhat-release")) + return(renv_bootstrap_platform_os_via_redhat_release()) + + "unknown" + + } + + renv_bootstrap_platform_os_via_os_release <- function(file, sysinfo) { + + # read /etc/os-release + release <- utils::read.table( + file = file, + sep = "=", + quote = c("\"", "'"), + col.names = c("Key", "Value"), + comment.char = "#", + stringsAsFactors = FALSE + ) + + vars <- as.list(release$Value) + names(vars) <- release$Key + + # get os name + os <- tolower(sysinfo[["sysname"]]) + + # read id + id <- "unknown" + for (field in c("ID", "ID_LIKE")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + id <- vars[[field]] + break + } + } + + # read version + version <- "unknown" + for (field in c("UBUNTU_CODENAME", "VERSION_CODENAME", "VERSION_ID", "BUILD_ID")) { + if (field %in% names(vars) && nzchar(vars[[field]])) { + version <- vars[[field]] + break + } + } + + # join together + paste(c(os, id, version), collapse = "-") + + } + + renv_bootstrap_platform_os_via_redhat_release <- function() { + + # read /etc/redhat-release + contents <- readLines("/etc/redhat-release", warn = FALSE) + + # infer id + id <- if (grepl("centos", contents, ignore.case = TRUE)) + "centos" + else if (grepl("redhat", contents, ignore.case = TRUE)) + "redhat" + else + "unknown" + + # try to find a version component (very hacky) + version <- "unknown" + + parts <- strsplit(contents, "[[:space:]]")[[1L]] + for (part in parts) { + + nv <- tryCatch(numeric_version(part), error = identity) + if (inherits(nv, "error")) + next + + version <- nv[1, 1] + break + + } + + paste(c("linux", id, version), collapse = "-") + + } + + renv_bootstrap_library_root_name <- function(project) { + + # use project name as-is if requested + asis <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT_ASIS", unset = "FALSE") + if (asis) + return(basename(project)) + + # otherwise, disambiguate based on project's path + id <- substring(renv_bootstrap_hash_text(project), 1L, 8L) + paste(basename(project), id, sep = "-") + + } + + renv_bootstrap_library_root <- function(project) { + + path <- Sys.getenv("RENV_PATHS_LIBRARY", unset = NA) + if (!is.na(path)) + return(path) + + path <- Sys.getenv("RENV_PATHS_LIBRARY_ROOT", unset = NA) + if (!is.na(path)) { + name <- renv_bootstrap_library_root_name(project) + return(file.path(path, name)) + } + + prefix <- renv_bootstrap_profile_prefix() + paste(c(project, prefix, "renv/library"), collapse = "/") + + } + + renv_bootstrap_validate_version <- function(version) { + + loadedversion <- utils::packageDescription("renv", fields = "Version") + if (version == loadedversion) + return(TRUE) + + # assume four-component versions are from GitHub; three-component + # versions are from CRAN + components <- strsplit(loadedversion, "[.-]")[[1]] + remote <- if (length(components) == 4L) + paste("rstudio/renv", loadedversion, sep = "@") + else + paste("renv", loadedversion, sep = "@") + + fmt <- paste( + "renv %1$s was loaded from project library, but this project is configured to use renv %2$s.", + "Use `renv::record(\"%3$s\")` to record renv %1$s in the lockfile.", + "Use `renv::restore(packages = \"renv\")` to install renv %2$s into the project library.", + sep = "\n" + ) + + msg <- sprintf(fmt, loadedversion, version, remote) + warning(msg, call. = FALSE) + + FALSE + + } + + renv_bootstrap_hash_text <- function(text) { + + hashfile <- tempfile("renv-hash-") + on.exit(unlink(hashfile), add = TRUE) + + writeLines(text, con = hashfile) + tools::md5sum(hashfile) + + } + + renv_bootstrap_load <- function(project, libpath, version) { + + # try to load renv from the project library + if (!requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) + return(FALSE) + + # warn if the version of renv loaded does not match + renv_bootstrap_validate_version(version) + + # load the project + renv::load(project) + + TRUE + + } + + renv_bootstrap_profile_load <- function(project) { + + # if RENV_PROFILE is already set, just use that + profile <- Sys.getenv("RENV_PROFILE", unset = NA) + if (!is.na(profile) && nzchar(profile)) + return(profile) + + # check for a profile file (nothing to do if it doesn't exist) + path <- file.path(project, "renv/local/profile") + if (!file.exists(path)) + return(NULL) + + # read the profile, and set it if it exists + contents <- readLines(path, warn = FALSE) + if (length(contents) == 0L) + return(NULL) + + # set RENV_PROFILE + profile <- contents[[1L]] + if (nzchar(profile)) + Sys.setenv(RENV_PROFILE = profile) + + profile + + } + + renv_bootstrap_profile_prefix <- function() { + profile <- renv_bootstrap_profile_get() + if (!is.null(profile)) + return(file.path("renv/profiles", profile)) + } + + renv_bootstrap_profile_get <- function() { + profile <- Sys.getenv("RENV_PROFILE", unset = "") + renv_bootstrap_profile_normalize(profile) + } + + renv_bootstrap_profile_set <- function(profile) { + profile <- renv_bootstrap_profile_normalize(profile) + if (is.null(profile)) + Sys.unsetenv("RENV_PROFILE") + else + Sys.setenv(RENV_PROFILE = profile) + } + + renv_bootstrap_profile_normalize <- function(profile) { + + if (is.null(profile) || profile %in% c("", "default")) + return(NULL) + + profile + + } + + # load the renv profile, if any + renv_bootstrap_profile_load(project) + + # construct path to library root + root <- renv_bootstrap_library_root(project) + + # construct library prefix for platform + prefix <- renv_bootstrap_platform_prefix() + + # construct full libpath + libpath <- file.path(root, prefix) + + # attempt to load + if (renv_bootstrap_load(project, libpath, version)) + return(TRUE) + + # load failed; inform user we're about to bootstrap + prefix <- paste("# Bootstrapping renv", version) + postfix <- paste(rep.int("-", 77L - nchar(prefix)), collapse = "") + header <- paste(prefix, postfix) + message(header) + + # perform bootstrap + bootstrap(version, libpath) + + # exit early if we're just testing bootstrap + if (!is.na(Sys.getenv("RENV_BOOTSTRAP_INSTALL_ONLY", unset = NA))) + return(TRUE) + + # try again to load + if (requireNamespace("renv", lib.loc = libpath, quietly = TRUE)) { + message("* Successfully installed and loaded renv ", version, ".") + return(renv::load()) + } + + # failed to download or load renv; warn the user + msg <- c( + "Failed to find an renv installation: the project will not be loaded.", + "Use `renv::activate()` to re-initialize the project." + ) + + warning(paste(msg, collapse = "\n"), call. = FALSE) + +}) diff --git a/renv/settings.dcf b/renv/settings.dcf new file mode 100644 index 0000000..fc4e479 --- /dev/null +++ b/renv/settings.dcf @@ -0,0 +1,8 @@ +external.libraries: +ignored.packages: +package.dependency.fields: Imports, Depends, LinkingTo +r.version: +snapshot.type: implicit +use.cache: TRUE +vcs.ignore.library: TRUE +vcs.ignore.local: TRUE diff --git a/rsconnect/shinyapps.io/ibidyouadu/liftboard.dcf b/rsconnect/shinyapps.io/ibidyouadu/liftboard.dcf new file mode 100644 index 0000000..88c1ffe --- /dev/null +++ b/rsconnect/shinyapps.io/ibidyouadu/liftboard.dcf @@ -0,0 +1,11 @@ +name: liftboard +title: +username: +account: ibidyouadu +server: shinyapps.io +hostUrl: https://api.shinyapps.io/v1 +appId: 4387740 +bundleId: 4821353 +url: https://ibidyouadu.shinyapps.io/liftboard/ +when: 1626331794.39995 +lastSyncTime: 1626331794.39997 diff --git a/server.R b/server.R new file mode 100644 index 0000000..79b14df --- /dev/null +++ b/server.R @@ -0,0 +1,95 @@ +# +# 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/ui.R b/ui.R new file mode 100644 index 0000000..3d4f7ae --- /dev/null +++ b/ui.R @@ -0,0 +1,47 @@ +# +# 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"))))) +)) -- 2.43.0