Last active
August 5, 2024 19:42
-
-
Save arraytools/7e7bd709a853d3339590506576bea3b0 to your computer and use it in GitHub Desktop.
RenvDocker example for Docker + Shiny. See https://appsilon.com/renv-with-docker/ for more details.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Base R Shiny image | |
| FROM rocker/shiny | |
| # Make a directory in the container | |
| RUN mkdir /home/shiny-app | |
| # Install Renv | |
| RUN R -e "install.packages('renv', repos = c(CRAN = 'https://cloud.r-project.org'))" | |
| # Copy Renv files and Shiny app | |
| WORKDIR /home/shiny-app/ | |
| RUN mkdir -p renv | |
| COPY app.R app.R | |
| COPY renv.lock renv.lock | |
| # COPY .Rprofile .Rprofile | |
| # COPY renv/activate.R renv/activate.R | |
| # COPY renv/settings.json renv/settings.json | |
| # Restore the R environment | |
| RUN R -e "renv::restore()" | |
| # Expose the application port | |
| EXPOSE 8180 | |
| # Run the R Shiny app | |
| CMD Rscript /home/shiny-app/app.R |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "R": { | |
| "Version": "4.3.2", | |
| "Repositories": [ | |
| { | |
| "Name": "CRAN", | |
| "URL": "https://packagemanager.posit.co/cran/latest" | |
| } | |
| ] | |
| }, | |
| "Packages": { | |
| "MASS": { | |
| "Package": "MASS", | |
| "Version": "7.3-60", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "grDevices", | |
| "graphics", | |
| "methods", | |
| "stats", | |
| "utils" | |
| ], | |
| "Hash": "a56a6365b3fa73293ea8d084be0d9bb0" | |
| }, | |
| "Matrix": { | |
| "Package": "Matrix", | |
| "Version": "1.6-1.1", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "grDevices", | |
| "graphics", | |
| "grid", | |
| "lattice", | |
| "methods", | |
| "stats", | |
| "utils" | |
| ], | |
| "Hash": "1a00d4828f33a9d690806e98bd17150c" | |
| }, | |
| "R6": { | |
| "Package": "R6", | |
| "Version": "2.5.1", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "470851b6d5d0ac559e9d01bb352b4021" | |
| }, | |
| "RColorBrewer": { | |
| "Package": "RColorBrewer", | |
| "Version": "1.1-3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "45f0398006e83a5b10b72a90663d8d8c" | |
| }, | |
| "Rcpp": { | |
| "Package": "Rcpp", | |
| "Version": "1.0.11", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "methods", | |
| "utils" | |
| ], | |
| "Hash": "ae6cbbe1492f4de79c45fce06f967ce8" | |
| }, | |
| "base64enc": { | |
| "Package": "base64enc", | |
| "Version": "0.1-3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "543776ae6848fde2f48ff3816d0628bc" | |
| }, | |
| "bslib": { | |
| "Package": "bslib", | |
| "Version": "0.6.1", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "base64enc", | |
| "cachem", | |
| "grDevices", | |
| "htmltools", | |
| "jquerylib", | |
| "jsonlite", | |
| "lifecycle", | |
| "memoise", | |
| "mime", | |
| "rlang", | |
| "sass" | |
| ], | |
| "Hash": "c0d8599494bc7fb408cd206bbdd9cab0" | |
| }, | |
| "cachem": { | |
| "Package": "cachem", | |
| "Version": "1.0.8", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "fastmap", | |
| "rlang" | |
| ], | |
| "Hash": "c35768291560ce302c0a6589f92e837d" | |
| }, | |
| "cli": { | |
| "Package": "cli", | |
| "Version": "3.6.2", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "utils" | |
| ], | |
| "Hash": "1216ac65ac55ec0058a6f75d7ca0fd52" | |
| }, | |
| "colorspace": { | |
| "Package": "colorspace", | |
| "Version": "2.1-0", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "grDevices", | |
| "graphics", | |
| "methods", | |
| "stats" | |
| ], | |
| "Hash": "f20c47fd52fae58b4e377c37bb8c335b" | |
| }, | |
| "commonmark": { | |
| "Package": "commonmark", | |
| "Version": "1.9.0", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Hash": "d691c61bff84bd63c383874d2d0c3307" | |
| }, | |
| "crayon": { | |
| "Package": "crayon", | |
| "Version": "1.5.2", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "grDevices", | |
| "methods", | |
| "utils" | |
| ], | |
| "Hash": "e8a1e41acf02548751f45c718d55aa6a" | |
| }, | |
| "digest": { | |
| "Package": "digest", | |
| "Version": "0.6.33", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "utils" | |
| ], | |
| "Hash": "b18a9cf3c003977b0cc49d5e76ebe48d" | |
| }, | |
| "dplyr": { | |
| "Package": "dplyr", | |
| "Version": "1.1.4", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "R6", | |
| "cli", | |
| "generics", | |
| "glue", | |
| "lifecycle", | |
| "magrittr", | |
| "methods", | |
| "pillar", | |
| "rlang", | |
| "tibble", | |
| "tidyselect", | |
| "utils", | |
| "vctrs" | |
| ], | |
| "Hash": "fedd9d00c2944ff00a0e2696ccf048ec" | |
| }, | |
| "ellipsis": { | |
| "Package": "ellipsis", | |
| "Version": "0.3.2", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "rlang" | |
| ], | |
| "Hash": "bb0eec2fe32e88d9e2836c2f73ea2077" | |
| }, | |
| "fansi": { | |
| "Package": "fansi", | |
| "Version": "1.0.6", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "grDevices", | |
| "utils" | |
| ], | |
| "Hash": "962174cf2aeb5b9eea581522286a911f" | |
| }, | |
| "farver": { | |
| "Package": "farver", | |
| "Version": "2.1.1", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Hash": "8106d78941f34855c440ddb946b8f7a5" | |
| }, | |
| "fastmap": { | |
| "Package": "fastmap", | |
| "Version": "1.1.1", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Hash": "f7736a18de97dea803bde0a2daaafb27" | |
| }, | |
| "fontawesome": { | |
| "Package": "fontawesome", | |
| "Version": "0.5.2", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "htmltools", | |
| "rlang" | |
| ], | |
| "Hash": "c2efdd5f0bcd1ea861c2d4e2a883a67d" | |
| }, | |
| "fs": { | |
| "Package": "fs", | |
| "Version": "1.6.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "methods" | |
| ], | |
| "Hash": "47b5f30c720c23999b913a1a635cf0bb" | |
| }, | |
| "gapminder": { | |
| "Package": "gapminder", | |
| "Version": "1.0.0", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "tibble" | |
| ], | |
| "Hash": "3a6fab978494586e851b8763996821d6" | |
| }, | |
| "generics": { | |
| "Package": "generics", | |
| "Version": "0.1.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "methods" | |
| ], | |
| "Hash": "15e9634c0fcd294799e9b2e929ed1b86" | |
| }, | |
| "ggplot2": { | |
| "Package": "ggplot2", | |
| "Version": "3.4.4", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "MASS", | |
| "R", | |
| "cli", | |
| "glue", | |
| "grDevices", | |
| "grid", | |
| "gtable", | |
| "isoband", | |
| "lifecycle", | |
| "mgcv", | |
| "rlang", | |
| "scales", | |
| "stats", | |
| "tibble", | |
| "vctrs", | |
| "withr" | |
| ], | |
| "Hash": "313d31eff2274ecf4c1d3581db7241f9" | |
| }, | |
| "glue": { | |
| "Package": "glue", | |
| "Version": "1.6.2", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "methods" | |
| ], | |
| "Hash": "4f2596dfb05dac67b9dc558e5c6fba2e" | |
| }, | |
| "gtable": { | |
| "Package": "gtable", | |
| "Version": "0.3.4", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "cli", | |
| "glue", | |
| "grid", | |
| "lifecycle", | |
| "rlang" | |
| ], | |
| "Hash": "b29cf3031f49b04ab9c852c912547eef" | |
| }, | |
| "htmltools": { | |
| "Package": "htmltools", | |
| "Version": "0.5.7", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "base64enc", | |
| "digest", | |
| "ellipsis", | |
| "fastmap", | |
| "grDevices", | |
| "rlang", | |
| "utils" | |
| ], | |
| "Hash": "2d7b3857980e0e0d0a1fd6f11928ab0f" | |
| }, | |
| "httpuv": { | |
| "Package": "httpuv", | |
| "Version": "1.6.13", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "R6", | |
| "Rcpp", | |
| "later", | |
| "promises", | |
| "utils" | |
| ], | |
| "Hash": "d23d2879001f3d82ee9dc38a9ef53c4c" | |
| }, | |
| "isoband": { | |
| "Package": "isoband", | |
| "Version": "0.2.7", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "grid", | |
| "utils" | |
| ], | |
| "Hash": "0080607b4a1a7b28979aecef976d8bc2" | |
| }, | |
| "jquerylib": { | |
| "Package": "jquerylib", | |
| "Version": "0.1.4", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "htmltools" | |
| ], | |
| "Hash": "5aab57a3bd297eee1c1d862735972182" | |
| }, | |
| "jsonlite": { | |
| "Package": "jsonlite", | |
| "Version": "1.8.8", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "methods" | |
| ], | |
| "Hash": "e1b9c55281c5adc4dd113652d9e26768" | |
| }, | |
| "labeling": { | |
| "Package": "labeling", | |
| "Version": "0.4.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "graphics", | |
| "stats" | |
| ], | |
| "Hash": "b64ec208ac5bc1852b285f665d6368b3" | |
| }, | |
| "later": { | |
| "Package": "later", | |
| "Version": "1.3.2", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "Rcpp", | |
| "rlang" | |
| ], | |
| "Hash": "a3e051d405326b8b0012377434c62b37" | |
| }, | |
| "lattice": { | |
| "Package": "lattice", | |
| "Version": "0.22-5", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "grDevices", | |
| "graphics", | |
| "grid", | |
| "stats", | |
| "utils" | |
| ], | |
| "Hash": "7c5e89f04e72d6611c77451f6331a091" | |
| }, | |
| "lifecycle": { | |
| "Package": "lifecycle", | |
| "Version": "1.0.4", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "cli", | |
| "glue", | |
| "rlang" | |
| ], | |
| "Hash": "b8552d117e1b808b09a832f589b79035" | |
| }, | |
| "magrittr": { | |
| "Package": "magrittr", | |
| "Version": "2.0.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "7ce2733a9826b3aeb1775d56fd305472" | |
| }, | |
| "memoise": { | |
| "Package": "memoise", | |
| "Version": "2.0.1", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "cachem", | |
| "rlang" | |
| ], | |
| "Hash": "e2817ccf4a065c5d9d7f2cfbe7c1d78c" | |
| }, | |
| "mgcv": { | |
| "Package": "mgcv", | |
| "Version": "1.9-0", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "Matrix", | |
| "R", | |
| "graphics", | |
| "methods", | |
| "nlme", | |
| "splines", | |
| "stats", | |
| "utils" | |
| ], | |
| "Hash": "086028ca0460d0c368028d3bda58f31b" | |
| }, | |
| "mime": { | |
| "Package": "mime", | |
| "Version": "0.12", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "tools" | |
| ], | |
| "Hash": "18e9c28c1d3ca1560ce30658b22ce104" | |
| }, | |
| "munsell": { | |
| "Package": "munsell", | |
| "Version": "0.5.0", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "colorspace", | |
| "methods" | |
| ], | |
| "Hash": "6dfe8bf774944bd5595785e3229d8771" | |
| }, | |
| "nlme": { | |
| "Package": "nlme", | |
| "Version": "3.1-163", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "graphics", | |
| "lattice", | |
| "stats", | |
| "utils" | |
| ], | |
| "Hash": "8d1938040a05566f4f7a14af4feadd6b" | |
| }, | |
| "pillar": { | |
| "Package": "pillar", | |
| "Version": "1.9.0", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "cli", | |
| "fansi", | |
| "glue", | |
| "lifecycle", | |
| "rlang", | |
| "utf8", | |
| "utils", | |
| "vctrs" | |
| ], | |
| "Hash": "15da5a8412f317beeee6175fbc76f4bb" | |
| }, | |
| "pkgconfig": { | |
| "Package": "pkgconfig", | |
| "Version": "2.0.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "utils" | |
| ], | |
| "Hash": "01f28d4278f15c76cddbea05899c5d6f" | |
| }, | |
| "promises": { | |
| "Package": "promises", | |
| "Version": "1.2.1", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R6", | |
| "Rcpp", | |
| "fastmap", | |
| "later", | |
| "magrittr", | |
| "rlang", | |
| "stats" | |
| ], | |
| "Hash": "0d8a15c9d000970ada1ab21405387dee" | |
| }, | |
| "rappdirs": { | |
| "Package": "rappdirs", | |
| "Version": "0.3.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "5e3c5dc0b071b21fa128676560dbe94d" | |
| }, | |
| "renv": { | |
| "Package": "renv", | |
| "Version": "1.0.3", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "utils" | |
| ], | |
| "Hash": "41b847654f567341725473431dd0d5ab" | |
| }, | |
| "rlang": { | |
| "Package": "rlang", | |
| "Version": "1.1.2", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "utils" | |
| ], | |
| "Hash": "50a6dbdc522936ca35afc5e2082ea91b" | |
| }, | |
| "sass": { | |
| "Package": "sass", | |
| "Version": "0.4.8", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R6", | |
| "fs", | |
| "htmltools", | |
| "rappdirs", | |
| "rlang" | |
| ], | |
| "Hash": "168f9353c76d4c4b0a0bbf72e2c2d035" | |
| }, | |
| "scales": { | |
| "Package": "scales", | |
| "Version": "1.3.0", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "R6", | |
| "RColorBrewer", | |
| "cli", | |
| "farver", | |
| "glue", | |
| "labeling", | |
| "lifecycle", | |
| "munsell", | |
| "rlang", | |
| "viridisLite" | |
| ], | |
| "Hash": "c19df082ba346b0ffa6f833e92de34d1" | |
| }, | |
| "shiny": { | |
| "Package": "shiny", | |
| "Version": "1.8.0", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "R6", | |
| "bslib", | |
| "cachem", | |
| "commonmark", | |
| "crayon", | |
| "ellipsis", | |
| "fastmap", | |
| "fontawesome", | |
| "glue", | |
| "grDevices", | |
| "htmltools", | |
| "httpuv", | |
| "jsonlite", | |
| "later", | |
| "lifecycle", | |
| "methods", | |
| "mime", | |
| "promises", | |
| "rlang", | |
| "sourcetools", | |
| "tools", | |
| "utils", | |
| "withr", | |
| "xtable" | |
| ], | |
| "Hash": "3a1f41807d648a908e3c7f0334bf85e6" | |
| }, | |
| "sourcetools": { | |
| "Package": "sourcetools", | |
| "Version": "0.1.7-1", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "5f5a7629f956619d519205ec475fe647" | |
| }, | |
| "tibble": { | |
| "Package": "tibble", | |
| "Version": "3.2.1", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "fansi", | |
| "lifecycle", | |
| "magrittr", | |
| "methods", | |
| "pillar", | |
| "pkgconfig", | |
| "rlang", | |
| "utils", | |
| "vctrs" | |
| ], | |
| "Hash": "a84e2cc86d07289b3b6f5069df7a004c" | |
| }, | |
| "tidyselect": { | |
| "Package": "tidyselect", | |
| "Version": "1.2.0", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "cli", | |
| "glue", | |
| "lifecycle", | |
| "rlang", | |
| "vctrs", | |
| "withr" | |
| ], | |
| "Hash": "79540e5fcd9e0435af547d885f184fd5" | |
| }, | |
| "utf8": { | |
| "Package": "utf8", | |
| "Version": "1.2.4", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "62b65c52671e6665f803ff02954446e9" | |
| }, | |
| "vctrs": { | |
| "Package": "vctrs", | |
| "Version": "0.6.5", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "cli", | |
| "glue", | |
| "lifecycle", | |
| "rlang" | |
| ], | |
| "Hash": "c03fa420630029418f7e6da3667aac4a" | |
| }, | |
| "viridisLite": { | |
| "Package": "viridisLite", | |
| "Version": "0.4.2", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R" | |
| ], | |
| "Hash": "c826c7c4241b6fc89ff55aaea3fa7491" | |
| }, | |
| "withr": { | |
| "Package": "withr", | |
| "Version": "2.5.2", | |
| "Source": "Repository", | |
| "Repository": "RSPM", | |
| "Requirements": [ | |
| "R", | |
| "grDevices", | |
| "graphics", | |
| "stats" | |
| ], | |
| "Hash": "4b25e70111b7d644322e9513f403a272" | |
| }, | |
| "xtable": { | |
| "Package": "xtable", | |
| "Version": "1.8-4", | |
| "Source": "Repository", | |
| "Repository": "CRAN", | |
| "Requirements": [ | |
| "R", | |
| "stats", | |
| "utils" | |
| ], | |
| "Hash": "b8acdf8af494d9ec19ccb2481a9b11c2" | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # The filename should be app.R | |
| library(shiny) | |
| library(dplyr) | |
| library(ggplot2) | |
| library(gapminder) | |
| # Specify the application port | |
| options(shiny.host = "0.0.0.0") | |
| options(shiny.port = 8180) | |
| ui <- fluidPage( | |
| sidebarLayout( | |
| sidebarPanel( | |
| tags$h4("Gapminder Dashboard"), | |
| tags$hr(), | |
| selectInput(inputId = "inContinent", label = "Continent", choices = unique(gapminder$continent), selected = "Europe") | |
| ), | |
| mainPanel( | |
| plotOutput(outputId = "outChartLifeExp"), | |
| plotOutput(outputId = "outChartGDP") | |
| ) | |
| ) | |
| ) | |
| server <- function(input, output, session) { | |
| # Filter data and store as reactive value | |
| data <- reactive({ | |
| gapminder %>% | |
| filter(continent == input$inContinent) %>% | |
| group_by(year) %>% | |
| summarise( | |
| AvgLifeExp = round(mean(lifeExp)), | |
| AvgGdpPercap = round(mean(gdpPercap), digits = 2) | |
| ) | |
| }) | |
| # Common properties for charts | |
| chart_theme <- ggplot2::theme( | |
| plot.title = element_text(hjust = 0.5, size = 20, face = "bold"), | |
| axis.title.x = element_text(size = 15), | |
| axis.title.y = element_text(size = 15), | |
| axis.text.x = element_text(size = 12), | |
| axis.text.y = element_text(size = 12) | |
| ) | |
| # Render Life Exp chart | |
| output$outChartLifeExp <- renderPlot({ | |
| ggplot(data(), aes(x = year, y = AvgLifeExp)) + | |
| geom_col(fill = "#0099f9") + | |
| geom_text(aes(label = AvgLifeExp), vjust = 2, size = 6, color = "#ffffff") + | |
| labs(title = paste("Average life expectancy in", input$inContinent)) + | |
| theme_classic() + | |
| chart_theme | |
| }) | |
| # Render GDP chart | |
| output$outChartGDP <- renderPlot({ | |
| ggplot(data(), aes(x = year, y = AvgGdpPercap)) + | |
| geom_line(color = "#f96000", size = 2) + | |
| geom_point(color = "#f96000", size = 5) + | |
| geom_label( | |
| aes(label = AvgGdpPercap), | |
| nudge_x = 0.25, | |
| nudge_y = 0.25 | |
| ) + | |
| labs(title = paste("Average GDP per capita in", input$inContinent)) + | |
| theme_classic() + | |
| chart_theme | |
| }) | |
| } | |
| shinyApp(ui = ui, server = server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment