├── header.html ├── google512329ce39e7f719.html ├── favicon.ico ├── images ├── code-org.png ├── git-intro.png ├── new-branch.png ├── data-planning.jpg ├── GitHub-Desktop.png ├── GitHub_pages_1.png ├── GitHub_pages_2.png ├── RStudio-screenshot.png ├── Week1-Screen-Shot.png ├── Week2-Screen-Shot.png ├── Week3-Screen-Shot.png ├── Week4-Screen-Shot.png ├── Week5-Screen-Shot.png ├── Week6-Screen-Shot.png ├── Week7-Screen-Shot.png ├── Week8-Screen-Shot.png ├── Week9-Screen-Shot.png ├── pull-request-github.png ├── ExtinctionRiskAnalysis.pdf ├── git-merge-conflict-gh.png ├── tools-logo-transparent.png └── Emblem-important-red.svg.png ├── Sim_6_5_2020_wild.RData ├── footer.html ├── site_libs ├── bootstrap-3.3.5 │ ├── css │ │ └── fonts │ │ │ ├── Lato.ttf │ │ │ ├── Roboto.ttf │ │ │ ├── Ubuntu.ttf │ │ │ ├── LatoBold.ttf │ │ │ ├── NewsCycle.ttf │ │ │ ├── OpenSans.ttf │ │ │ ├── Raleway.ttf │ │ │ ├── LatoItalic.ttf │ │ │ ├── RalewayBold.ttf │ │ │ ├── RobotoBold.ttf │ │ │ ├── RobotoLight.ttf │ │ │ ├── NewsCycleBold.ttf │ │ │ ├── OpenSansBold.ttf │ │ │ ├── OpenSansItalic.ttf │ │ │ ├── OpenSansLight.ttf │ │ │ ├── RobotoMedium.ttf │ │ │ ├── SourceSansPro.ttf │ │ │ ├── OpenSansBoldItalic.ttf │ │ │ ├── OpenSansLightItalic.ttf │ │ │ ├── SourceSansProBold.ttf │ │ │ ├── SourceSansProItalic.ttf │ │ │ └── SourceSansProLight.ttf │ ├── fonts │ │ ├── glyphicons-halflings-regular.eot │ │ ├── glyphicons-halflings-regular.ttf │ │ ├── glyphicons-halflings-regular.woff │ │ └── glyphicons-halflings-regular.woff2 │ ├── js │ │ └── npm.js │ └── shim │ │ ├── html5shiv.min.js │ │ └── respond.min.js ├── font-awesome-5.1.0 │ └── webfonts │ │ ├── fa-solid-900.eot │ │ ├── fa-solid-900.ttf │ │ ├── fa-brands-400.eot │ │ ├── fa-brands-400.ttf │ │ ├── fa-brands-400.woff │ │ ├── fa-regular-400.eot │ │ ├── fa-regular-400.ttf │ │ ├── fa-solid-900.woff │ │ ├── fa-solid-900.woff2 │ │ ├── fa-brands-400.woff2 │ │ ├── fa-regular-400.woff │ │ └── fa-regular-400.woff2 ├── jqueryui-1.11.4 │ ├── images │ │ ├── ui-icons_444444_256x240.png │ │ ├── ui-icons_555555_256x240.png │ │ ├── ui-icons_777620_256x240.png │ │ ├── ui-icons_777777_256x240.png │ │ ├── ui-icons_cc0000_256x240.png │ │ └── ui-icons_ffffff_256x240.png │ ├── README │ └── jquery-ui.structure.min.css ├── kePrint-0.0.1 │ └── kePrint.js ├── highlightjs-9.12.0 │ ├── default.css │ └── textmate.css ├── navigation-1.1 │ ├── sourceembed.js │ ├── codefolding.js │ └── tabsets.js ├── header-attrs-2.7 │ └── header-attrs.js ├── tocify-1.9.1 │ └── jquery.tocify.css └── lightable-0.0.1 │ └── lightable.css ├── coding_files └── figure-html │ ├── unnamed-chunk-6-1.png │ ├── unnamed-chunk-7-1.png │ └── unnamed-chunk-25-1.png ├── RMarkdown_files └── figure-html │ └── unnamed-chunk-1-1.png ├── packages_files └── figure-html │ └── unnamed-chunk-3-1.png ├── search.Rmd ├── week2-coding_files └── figure-html │ ├── unnamed-chunk-25-1.png │ ├── unnamed-chunk-6-1.png │ └── unnamed-chunk-7-1.png ├── week4-packages_files └── figure-html │ ├── unnamed-chunk-3-1.png │ └── unnamed-chunk-4-1.png ├── week8-ggplot2_files └── figure-html │ ├── unnamed-chunk-10-1.png │ ├── unnamed-chunk-11-1.png │ ├── unnamed-chunk-12-1.png │ ├── unnamed-chunk-13-1.png │ ├── unnamed-chunk-14-1.png │ ├── unnamed-chunk-15-1.png │ ├── unnamed-chunk-16-1.png │ ├── unnamed-chunk-17-1.png │ ├── unnamed-chunk-18-1.png │ ├── unnamed-chunk-19-1.png │ ├── unnamed-chunk-2-1.png │ ├── unnamed-chunk-20-1.png │ ├── unnamed-chunk-21-1.png │ ├── unnamed-chunk-22-1.png │ ├── unnamed-chunk-23-1.png │ ├── unnamed-chunk-24-1.png │ ├── unnamed-chunk-25-1.png │ ├── unnamed-chunk-26-1.png │ ├── unnamed-chunk-27-1.png │ ├── unnamed-chunk-28-1.png │ ├── unnamed-chunk-29-1.png │ ├── unnamed-chunk-3-1.png │ ├── unnamed-chunk-30-1.png │ ├── unnamed-chunk-31-1.png │ ├── unnamed-chunk-32-1.png │ ├── unnamed-chunk-33-1.png │ ├── unnamed-chunk-34-1.png │ ├── unnamed-chunk-35-1.png │ ├── unnamed-chunk-36-1.png │ ├── unnamed-chunk-37-1.png │ ├── unnamed-chunk-38-1.png │ ├── unnamed-chunk-39-1.png │ ├── unnamed-chunk-4-1.png │ ├── unnamed-chunk-40-1.png │ ├── unnamed-chunk-5-1.png │ ├── unnamed-chunk-6-1.png │ ├── unnamed-chunk-7-1.png │ ├── unnamed-chunk-8-1.png │ └── unnamed-chunk-9-1.png ├── week3-RMarkdown_files └── figure-html │ └── unnamed-chunk-1-1.png ├── week9-data-wrangling_files └── figure-html │ ├── unnamed-chunk-11-1.png │ ├── unnamed-chunk-12-1.png │ ├── unnamed-chunk-14-1.png │ ├── unnamed-chunk-15-1.png │ ├── unnamed-chunk-18-1.png │ ├── unnamed-chunk-19-1.png │ ├── unnamed-chunk-44-1.png │ ├── unnamed-chunk-45-1.png │ ├── unnamed-chunk-48-1.png │ ├── unnamed-chunk-49-1.png │ ├── unnamed-chunk-5-1.png │ ├── unnamed-chunk-51-1.png │ ├── unnamed-chunk-52-1.png │ ├── unnamed-chunk-55-1.png │ ├── unnamed-chunk-56-1.png │ └── unnamed-chunk-6-1.png ├── RWorkflow-NWFSC-2020.Rproj ├── README.md ├── fitfun.R ├── .gitignore ├── styles.css ├── salmon.R ├── salmon.Rmd ├── data ├── steelhead.csv └── salmon.csv ├── bookdown.Rmd ├── _site.yml ├── index.Rmd ├── jekyll.Rmd ├── more-git.Rmd ├── links.Rmd ├── gitlab-to-github.Rmd ├── shiny.Rmd ├── week5-roxygen.Rmd ├── LICENSE ├── Git-RStudio.Rmd ├── websites.Rmd ├── README.html ├── intro-git.Rmd ├── week1-rstudio.Rmd ├── week3-RMarkdown.Rmd ├── week9-data-wrangling.R ├── week7-more-git.Rmd └── week6-more-packages.Rmd /header.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /google512329ce39e7f719.html: -------------------------------------------------------------------------------- 1 | google-site-verification: google512329ce39e7f719.html -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/favicon.ico -------------------------------------------------------------------------------- /images/code-org.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/code-org.png -------------------------------------------------------------------------------- /images/git-intro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/git-intro.png -------------------------------------------------------------------------------- /images/new-branch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/new-branch.png -------------------------------------------------------------------------------- /Sim_6_5_2020_wild.RData: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/Sim_6_5_2020_wild.RData -------------------------------------------------------------------------------- /images/data-planning.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/data-planning.jpg -------------------------------------------------------------------------------- /images/GitHub-Desktop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/GitHub-Desktop.png -------------------------------------------------------------------------------- /images/GitHub_pages_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/GitHub_pages_1.png -------------------------------------------------------------------------------- /images/GitHub_pages_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/GitHub_pages_2.png -------------------------------------------------------------------------------- /images/RStudio-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/RStudio-screenshot.png -------------------------------------------------------------------------------- /images/Week1-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week1-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week2-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week2-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week3-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week3-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week4-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week4-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week5-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week5-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week6-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week6-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week7-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week7-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week8-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week8-Screen-Shot.png -------------------------------------------------------------------------------- /images/Week9-Screen-Shot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Week9-Screen-Shot.png -------------------------------------------------------------------------------- /images/pull-request-github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/pull-request-github.png -------------------------------------------------------------------------------- /images/ExtinctionRiskAnalysis.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/ExtinctionRiskAnalysis.pdf -------------------------------------------------------------------------------- /images/git-merge-conflict-gh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/git-merge-conflict-gh.png -------------------------------------------------------------------------------- /images/tools-logo-transparent.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/tools-logo-transparent.png -------------------------------------------------------------------------------- /images/Emblem-important-red.svg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/images/Emblem-important-red.svg.png -------------------------------------------------------------------------------- /footer.html: -------------------------------------------------------------------------------- 1 |
2 | 3 |
4 | NWFSC Math Bio Program 5 |
-------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Lato.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/Lato.ttf -------------------------------------------------------------------------------- /coding_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/coding_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /coding_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/coding_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Roboto.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/Roboto.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Ubuntu.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/Ubuntu.ttf -------------------------------------------------------------------------------- /RMarkdown_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/RMarkdown_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /coding_files/figure-html/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/coding_files/figure-html/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /packages_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/packages_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/LatoBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/LatoBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/NewsCycle.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/NewsCycle.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSans.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/OpenSans.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/Raleway.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/Raleway.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/LatoItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/LatoItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RalewayBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/RalewayBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RobotoBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/RobotoBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RobotoLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/RobotoLight.ttf -------------------------------------------------------------------------------- /search.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Search" 3 | --- 4 | 5 | 6 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/NewsCycleBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/NewsCycleBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/OpenSansBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/OpenSansItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/OpenSansLight.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/RobotoMedium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/RobotoMedium.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansPro.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/SourceSansPro.ttf -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.eot -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.ttf -------------------------------------------------------------------------------- /week2-coding_files/figure-html/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week2-coding_files/figure-html/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /week2-coding_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week2-coding_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /week2-coding_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week2-coding_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /week4-packages_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week4-packages_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /week4-packages_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week4-packages_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-10-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-10-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-13-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-13-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-16-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-16-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-17-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-17-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-2-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-2-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-20-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-20-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-21-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-21-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-22-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-22-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-23-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-23-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-24-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-24-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-25-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-25-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-26-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-26-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-27-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-27-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-28-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-28-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-29-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-29-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-3-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-3-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-30-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-30-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-31-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-31-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-32-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-32-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-33-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-33-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-34-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-34-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-35-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-35-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-36-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-36-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-37-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-37-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-38-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-38-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-39-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-39-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-4-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-4-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-40-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-40-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-7-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-7-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-8-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-8-1.png -------------------------------------------------------------------------------- /week8-ggplot2_files/figure-html/unnamed-chunk-9-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week8-ggplot2_files/figure-html/unnamed-chunk-9-1.png -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.eot -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.ttf -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.woff -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.eot -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.ttf -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.woff -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-solid-900.woff2 -------------------------------------------------------------------------------- /week3-RMarkdown_files/figure-html/unnamed-chunk-1-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week3-RMarkdown_files/figure-html/unnamed-chunk-1-1.png -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansBoldItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/OpenSansBoldItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/OpenSansLightItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/OpenSansLightItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansProBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/SourceSansProBold.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansProItalic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/SourceSansProItalic.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/css/fonts/SourceSansProLight.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/css/fonts/SourceSansProLight.ttf -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-brands-400.woff2 -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.woff -------------------------------------------------------------------------------- /site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/font-awesome-5.1.0/webfonts/fa-regular-400.woff2 -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_444444_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/jqueryui-1.11.4/images/ui-icons_444444_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_555555_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/jqueryui-1.11.4/images/ui-icons_555555_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_777620_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/jqueryui-1.11.4/images/ui-icons_777620_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_777777_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/jqueryui-1.11.4/images/ui-icons_777777_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_cc0000_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/jqueryui-1.11.4/images/ui-icons_cc0000_256x240.png -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/images/ui-icons_ffffff_256x240.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/jqueryui-1.11.4/images/ui-icons_ffffff_256x240.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-11-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-11-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-12-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-12-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-14-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-14-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-15-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-15-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-18-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-18-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-19-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-19-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-44-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-44-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-45-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-45-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-48-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-48-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-49-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-49-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-5-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-5-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-51-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-51-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-52-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-52-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-55-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-55-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-56-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-56-1.png -------------------------------------------------------------------------------- /week9-data-wrangling_files/figure-html/unnamed-chunk-6-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/week9-data-wrangling_files/figure-html/unnamed-chunk-6-1.png -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/RVerse-Tutorials/RWorkflow-NWFSC-2020/master/site_libs/bootstrap-3.3.5/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /RWorkflow-NWFSC-2020.Rproj: -------------------------------------------------------------------------------- 1 | Version: 1.0 2 | 3 | RestoreWorkspace: No 4 | SaveWorkspace: No 5 | AlwaysSaveHistory: Yes 6 | 7 | EnableCodeIndexing: Yes 8 | UseSpacesForTab: Yes 9 | NumSpacesForTab: 2 10 | Encoding: UTF-8 11 | 12 | RnwWeave: Sweave 13 | LaTeX: pdfLaTeX 14 | 15 | BuildType: Website 16 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RWorkflow-NWFSC-2020 2 | R Workflow workshop material for NWFSC workshops May-June 2020 3 | 4 | ## Re-use Statement 5 | 6 | This work is released under a Creative Commons license. You are free to use, copy and adapt the material. It'd be nice if you gave me credit, but this is not required. 7 | 8 | -------------------------------------------------------------------------------- /site_libs/kePrint-0.0.1/kePrint.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function(){ 2 | if (typeof $('[data-toggle="tooltip"]').tooltip === 'function') { 3 | $('[data-toggle="tooltip"]').tooltip(); 4 | } 5 | if ($('[data-toggle="popover"]').popover === 'function') { 6 | $('[data-toggle="popover"]').popover(); 7 | } 8 | }); 9 | -------------------------------------------------------------------------------- /site_libs/highlightjs-9.12.0/default.css: -------------------------------------------------------------------------------- 1 | .hljs-literal { 2 | color: #990073; 3 | } 4 | 5 | .hljs-number { 6 | color: #099; 7 | } 8 | 9 | .hljs-comment { 10 | color: #998; 11 | font-style: italic; 12 | } 13 | 14 | .hljs-keyword { 15 | color: #900; 16 | font-weight: bold; 17 | } 18 | 19 | .hljs-string { 20 | color: #d14; 21 | } 22 | -------------------------------------------------------------------------------- /site_libs/highlightjs-9.12.0/textmate.css: -------------------------------------------------------------------------------- 1 | .hljs-literal { 2 | color: rgb(88, 72, 246); 3 | } 4 | 5 | .hljs-number { 6 | color: rgb(0, 0, 205); 7 | } 8 | 9 | .hljs-comment { 10 | color: rgb(76, 136, 107); 11 | } 12 | 13 | .hljs-keyword { 14 | color: rgb(0, 0, 255); 15 | } 16 | 17 | .hljs-string { 18 | color: rgb(3, 106, 7); 19 | } 20 | -------------------------------------------------------------------------------- /fitfun.R: -------------------------------------------------------------------------------- 1 | fitfun <- function(x, max.train.year=2010, fun="gam", response.var="wild", covariate="flow"){ 2 | subx <- subset(x, year :first-child"); 5 | var i, h, a; 6 | for (i = 0; i < hs.length; i++) { 7 | h = hs[i]; 8 | if (!/^h[1-6]$/i.test(h.tagName)) continue; // it should be a header h1-h6 9 | a = h.attributes; 10 | while (a.length > 0) h.removeAttribute(a[0].name); 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # History files 2 | .Rhistory 3 | .Rapp.history 4 | 5 | # MAC stuff 6 | .DS_Store 7 | 8 | # Session Data files 9 | .RData 10 | 11 | # User-specific files 12 | .Ruserdata 13 | 14 | # Example code in package build process 15 | *-Ex.R 16 | 17 | # Output files from R CMD build 18 | /*.tar.gz 19 | 20 | # Output files from R CMD check 21 | /*.Rcheck/ 22 | 23 | # RStudio files 24 | .Rproj.user/ 25 | 26 | # produced vignettes 27 | vignettes/*.html 28 | vignettes/*.pdf 29 | 30 | # OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3 31 | .httr-oauth 32 | 33 | # knitr and R markdown default cache directories 34 | *_cache/ 35 | /cache/ 36 | 37 | # Temporary files created by R markdown 38 | *.utf8.md 39 | *.knit.md 40 | 41 | # R Environment Variables 42 | .Renviron 43 | .Rproj.user 44 | 45 | # Debug files 46 | Rprof.out 47 | Rprof.out 48 | *.out 49 | .DS_Store 50 | -------------------------------------------------------------------------------- /styles.css: -------------------------------------------------------------------------------- 1 | /* Need to adjust the navbar behaviour so the navbar doesn't wrap */ 2 | .navbar-nav { 3 | position: fixed; 4 | left: 150px; 5 | width: 1000px; 6 | } 7 | 8 | .navbar-right { 9 | position: fixed; 10 | left: 80%; 11 | width: 300px; 12 | } 13 | 14 | .navbar-header { 15 | position: fixed; 16 | left: 30px; 17 | width: 97%; 18 | } 19 | 20 | .nav { 21 | font-size: 15px; 22 | } 23 | 24 | body { 25 | font-family: "Raleway","Helvetica Neue",Helvetica,Arial,sans-serif; 26 | line-height: 2; 27 | } 28 | 29 | div.scroll { 30 | background-color: #FFFFFF; 31 | height:225px; 32 | width: 100%; 33 | overflow-x: scroll; 34 | } 35 | 36 | blockquote { 37 | border-left:none; 38 | font-size: 1em; 39 | display: block; 40 | margin-top: .25em; 41 | margin-left: 20px; 42 | } 43 | 44 | h1 { 45 | padding-bottom: 0.5em; 46 | } 47 | 48 | .section { 49 | padding-bottom: 2em; 50 | } 51 | -------------------------------------------------------------------------------- /salmon.R: -------------------------------------------------------------------------------- 1 | #Set your working directory 2 | setwd('~/GitHub/RWorkflow-NWFSC-2020/') 3 | #setwd('C:Users/Eli.Holmes/Workshops/RWorkflow-NWFSC-2020/') 4 | 5 | #-----Read in salmon data---- 6 | fil <- "data/salmon.csv" 7 | saldat <- read.csv(fil) 8 | colnames(saldat) <- c("year", "wild", "flow", "temp") 9 | fil <- "data/steelhead.csv" 10 | steeldat <- as.matrix(read.csv(fil)) 11 | 12 | #Create training and testing data frames 13 | dat1 <- saldat[saldat$year<=2010,] 14 | dat2 <- saldat[saldat$year>2010,] 15 | 16 | # gam fit 17 | library(mgcv) 18 | fit1 <- gam(wild ~ s(flow), data=dat1) 19 | fit2 <- lm(steeldat[1,1:30] ~ steeldat[2,1:30]) 20 | library(forecast) 21 | dat <- dat1$wild 22 | fit3 <- auto.arima(dat) 23 | 24 | #Save data 25 | save(fit1, fit2, fit3, file="Sim_6_5_2020_wild.RData") #save data 26 | 27 | #Make some plots 28 | plot(fit1) 29 | plot(fit2) 30 | 31 | pred1 <- predict(fit1, newdata=data.frame(dat2)) 32 | plot(dat1$year, dat1$wild, xlim=c(1980,2020), type="l") 33 | lines(dat2$year, dat2$wild, col="blue") 34 | lines(dat2$year, pred1, col="red", lty=2) 35 | 36 | pred2 <- predict(fit2, newdata=data.frame(dat2)) 37 | plot(dat1$year, dat1$wild, xlim=c(1980,2020), type="l") 38 | lines(dat2$year, dat2$wild, col="blue") 39 | lines(dat2$year, pred2, col="red", lty=2) 40 | 41 | pred3 <- forecast(fit3, h=9) 42 | plot(dat1$year, dat1$wild, xlim=c(1980,2020), type="l") 43 | lines(dat2$year, dat2$wild, col="blue") 44 | lines(dat2$year, pred3$mean, col="red", lty=2) 45 | -------------------------------------------------------------------------------- /salmon.Rmd: -------------------------------------------------------------------------------- 1 | ``` 2 | #Set your working directory 3 | setwd('~/GitHub/RWorkflow-NWFSC-2020/') 4 | #setwd('C:Users/Eli.Holmes/Workshops/RWorkflow-NWFSC-2020/') 5 | 6 | #-----Read in salmon data---- 7 | fil <- "data/salmon.csv" 8 | saldat <- read.csv(fil) 9 | colnames(saldat) <- c("year", "wild", "flow", "temp") 10 | fil <- "steelhead.csv" 11 | steeldat <- as.matrix(read.csv(fil)) 12 | 13 | #Create training and testing data frames 14 | dat1 <- saldat[saldat$year<=2010,] 15 | dat2 <- saldat[saldat$year>2010,] 16 | 17 | # gam fit 18 | library(mgcv) 19 | fit1 <- gam(wild ~ s(flow), data=dat1) 20 | fit2 <- lm(steeldat[1,1:30] ~ steeldat[2,1:30]) 21 | library(forecast) 22 | dat <- dat1$wild 23 | fit3 <- auto.arima(dat) 24 | 25 | #Save data 26 | save(fit1, fit2, fit3, file="Sim_6_5_2020_wild.RData") #save data 27 | 28 | #Make some plots 29 | plot(fit1) 30 | plot(fit2) 31 | 32 | pred1 <- predict(fit1, newdata=data.frame(dat2)) 33 | plot(dat1$year, dat1$wild, xlim=c(1980,2020), type="l") 34 | lines(dat2$year, dat2$wild, col="blue") 35 | lines(dat2$year, pred1, col="red", lty=2) 36 | 37 | pred2 <- predict(fit2, newdata=data.frame(dat2)) 38 | plot(dat1$year, dat1$wild, xlim=c(1980,2020), type="l") 39 | lines(dat2$year, dat2$wild, col="blue") 40 | lines(dat2$year, pred2, col="red", lty=2) 41 | 42 | pred3 <- forecast(fit3, h=9) 43 | plot(dat1$year, dat1$wild, xlim=c(1980,2020), type="l") 44 | lines(dat2$year, dat2$wild, col="blue") 45 | lines(dat2$year, pred3$mean, col="red", lty=2) 46 | ``` 47 | 48 | Let's take the fitting lines and make a function. 49 | 50 | ``` 51 | fitfun <- function(x, max.train.year=2010, fun="gam", response.var="wild", covariate="flow"){ 52 | subx <- subset(x, year'); 25 | var showThis = (show || $(this).hasClass('fold-show')) && !$(this).hasClass('fold-hide'); 26 | if (showThis) div.collapse('show'); 27 | var id = 'rcode-643E0F36' + currentIndex++; 28 | div.attr('id', id); 29 | $(this).before(div); 30 | $(this).detach().appendTo(div); 31 | 32 | // add a show code button right above 33 | var showCodeText = $('' + (showThis ? 'Hide' : 'Code') + ''); 34 | var showCodeButton = $(''); 35 | showCodeButton.append(showCodeText); 36 | showCodeButton 37 | .attr('data-toggle', 'collapse') 38 | .attr('data-target', '#' + id) 39 | .attr('aria-expanded', showThis) 40 | .attr('aria-controls', id); 41 | 42 | var buttonRow = $('
'); 43 | var buttonCol = $('
'); 44 | 45 | buttonCol.append(showCodeButton); 46 | buttonRow.append(buttonCol); 47 | 48 | div.before(buttonRow); 49 | 50 | // update state of button on show/hide 51 | div.on('hidden.bs.collapse', function () { 52 | showCodeText.text('Code'); 53 | }); 54 | div.on('show.bs.collapse', function () { 55 | showCodeText.text('Hide'); 56 | }); 57 | }); 58 | 59 | } 60 | -------------------------------------------------------------------------------- /data/steelhead.csv: -------------------------------------------------------------------------------- 1 | "1980","1981","1982","1983","1984","1985","1986","1987","1988","1989","1990","1991","1992","1993","1994","1995","1996","1997","1998","1999","2000","2001","2002","2003","2004","2005","2006","2007","2008","2009","2010","2011","2012","2013","2014","2015","2016","2017","2018","2019" 2 | 0.25710694085556,1.27888159424569,0.700261152771668,0.578685392103179,0.65922231414361,1.08558564446821,-0.618600777108161,-0.127992184374197,-0.554676595525759,-1.95227719612623,-1.91839671427212,-1.64556773764974,-2.43242404046792,-1.09236820876189,-1.5029280861692,-2.11140045636105,-2.11765357567657,-2.57741244378835,-0.638323186720977,-0.901788876019664,-1.3056312210391,-1.90891545290886,-3.30601110236771,-4.49208064241213,-3.28022562742422,-4.24387636929799,-2.64906777010238,-1.8596878760439,-0.194728332123382,-0.491434961479704,-0.432262815986725,-0.814246499418554,-0.959280952479514,-2.03265348574278,-3.21070344322019,-3.33458467062747,-3.66512237538969,-4.33069083749071,-4.68577448323806,-5.00042123197975 3 | 10.1625752243153,9.97602546817873,9.80175091432538,9.994152295109,9.94896904913467,10.0500215687013,10.0180860153817,9.91697542106213,9.91908004121749,9.92781075762355,10.1855849140549,10.0403387438053,10.0108033568592,9.79907848369066,10.0291943441462,9.9679594582624,9.96318852899115,9.86303731814278,10.0340263048403,10.0029898072197,9.89198660063348,9.99271465961344,10.0260432406474,9.9967444522504,10.0954395520489,9.81623934778727,10.0515416315785,9.89836621352881,9.94948420130299,9.97841583210208,9.82479706917606,9.85382097920532,9.98883449390117,10.0018204569202,9.79498537294423,9.90836417716676,9.89152405029709,9.90756493092377,9.9655054085575,9.86174599399101 4 | 28.1065443281085,27.9095713889374,28.0848792441965,28.0621825105521,27.921791832515,28.2228416583227,27.9119123088044,28.0478079500053,27.9467323856459,27.9868683574651,28.3364423664596,27.9089887382113,28.1384989868964,27.9491401603986,28.1476337889752,28.0405672306051,28.083983972754,28.0725060643988,28.00314851546,28.0849195077866,28.151467537738,27.8794012124938,28.1673024301322,27.9959836934756,28.0213900132652,27.821226106826,28.0217082689883,28.0346359067877,28.0018361356858,28.1524613421861,28.0534812684974,27.907841092211,27.8032203700241,27.924653577602,27.9296479549649,28.0189149061395,28.0120151304275,27.9779699336324,27.9978132091214,28.0329741565827 5 | -------------------------------------------------------------------------------- /site_libs/tocify-1.9.1/jquery.tocify.css: -------------------------------------------------------------------------------- 1 | /* 2 | * jquery.tocify.css 1.9.1 3 | * Author: @gregfranko 4 | */ 5 | 6 | /* The Table of Contents container element */ 7 | .tocify { 8 | width: 20%; 9 | max-height: 90%; 10 | overflow: auto; 11 | margin-left: 2%; 12 | position: fixed; 13 | border: 1px solid #ccc; 14 | border-radius: 6px; 15 | } 16 | 17 | /* The Table of Contents is composed of multiple nested unordered lists. These styles remove the default styling of an unordered list because it is ugly. */ 18 | .tocify ul, .tocify li { 19 | list-style: none; 20 | margin: 0; 21 | padding: 0; 22 | border: none; 23 | line-height: 30px; 24 | } 25 | 26 | /* Top level header elements */ 27 | .tocify-header { 28 | text-indent: 10px; 29 | } 30 | 31 | /* Top level subheader elements. These are the first nested items underneath a header element. */ 32 | .tocify-subheader { 33 | text-indent: 20px; 34 | display: none; 35 | } 36 | 37 | /* Makes the font smaller for all subheader elements. */ 38 | .tocify-subheader li { 39 | font-size: 12px; 40 | } 41 | 42 | /* Further indents second level subheader elements. */ 43 | .tocify-subheader .tocify-subheader { 44 | text-indent: 30px; 45 | } 46 | .tocify-subheader .tocify-subheader .tocify-subheader { 47 | text-indent: 40px; 48 | } 49 | .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader { 50 | text-indent: 50px; 51 | } 52 | .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader .tocify-subheader { 53 | text-indent: 60px; 54 | } 55 | 56 | /* Twitter Bootstrap Override Style */ 57 | .tocify .tocify-item > a, .tocify .nav-list .nav-header { 58 | margin: 0px; 59 | } 60 | 61 | /* Twitter Bootstrap Override Styles */ 62 | .tocify .tocify-item a, .tocify .list-group-item { 63 | padding: 5px; 64 | } 65 | 66 | .tocify .nav-pills > li { 67 | float: none; 68 | } 69 | 70 | /* We don't override the bootstrap colors because this gives us the 71 | wrong selection colors when using bootstrap themes 72 | 73 | .tocify .list-group-item:hover, .tocify .list-group-item:focus { 74 | background-color: #f5f5f5; 75 | } 76 | 77 | .tocify .list-group-item.active:hover, .tocify .list-group-item.active:focus { 78 | background-color: #428bca; 79 | } 80 | */ 81 | 82 | /* End Twitter Bootstrap Override Styles */ 83 | -------------------------------------------------------------------------------- /data/salmon.csv: -------------------------------------------------------------------------------- 1 | "year","POPULATION","GAUGE_X1","SST_v21" 2 | 1980,0.25710694085556,10.1625752243153,28.1065443281085 3 | 1981,1.27888159424569,9.97602546817873,27.9095713889374 4 | 1982,0.700261152771668,9.80175091432538,28.0848792441965 5 | 1983,0.578685392103179,9.994152295109,28.0621825105521 6 | 1984,0.65922231414361,9.94896904913467,27.921791832515 7 | 1985,1.08558564446821,10.0500215687013,28.2228416583227 8 | 1986,-0.618600777108161,10.0180860153817,27.9119123088044 9 | 1987,-0.127992184374197,9.91697542106213,28.0478079500053 10 | 1988,-0.554676595525759,9.91908004121749,27.9467323856459 11 | 1989,-1.95227719612623,9.92781075762355,27.9868683574651 12 | 1990,-1.91839671427212,10.1855849140549,28.3364423664596 13 | 1991,-1.64556773764974,10.0403387438053,27.9089887382113 14 | 1992,-2.43242404046792,10.0108033568592,28.1384989868964 15 | 1993,-1.09236820876189,9.79907848369066,27.9491401603986 16 | 1994,-1.5029280861692,10.0291943441462,28.1476337889752 17 | 1995,-2.11140045636105,9.9679594582624,28.0405672306051 18 | 1996,-2.11765357567657,9.96318852899115,28.083983972754 19 | 1997,-2.57741244378835,9.86303731814278,28.0725060643988 20 | 1998,-0.638323186720977,10.0340263048403,28.00314851546 21 | 1999,-0.901788876019664,10.0029898072197,28.0849195077866 22 | 2000,-1.3056312210391,9.89198660063348,28.151467537738 23 | 2001,-1.90891545290886,9.99271465961344,27.8794012124938 24 | 2002,-3.30601110236771,10.0260432406474,28.1673024301322 25 | 2003,-4.49208064241213,9.9967444522504,27.9959836934756 26 | 2004,-3.28022562742422,10.0954395520489,28.0213900132652 27 | 2005,-4.24387636929799,9.81623934778727,27.821226106826 28 | 2006,-2.64906777010238,10.0515416315785,28.0217082689883 29 | 2007,-1.8596878760439,9.89836621352881,28.0346359067877 30 | 2008,-0.194728332123382,9.94948420130299,28.0018361356858 31 | 2009,-0.491434961479704,9.97841583210208,28.1524613421861 32 | 2010,-0.432262815986725,9.82479706917606,28.0534812684974 33 | 2011,-0.814246499418554,9.85382097920532,27.907841092211 34 | 2012,-0.959280952479514,9.98883449390117,27.8032203700241 35 | 2013,-2.03265348574278,10.0018204569202,27.924653577602 36 | 2014,-3.21070344322019,9.79498537294423,27.9296479549649 37 | 2015,-3.33458467062747,9.90836417716676,28.0189149061395 38 | 2016,-3.66512237538969,9.89152405029709,28.0120151304275 39 | 2017,-4.33069083749071,9.90756493092377,27.9779699336324 40 | 2018,-4.68577448323806,9.9655054085575,27.9978132091214 41 | 2019,-5.00042123197975,9.86174599399101,28.0329741565827 42 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/shim/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | // Only run this code in IE 8 5 | if (!!window.navigator.userAgent.match("MSIE 8")) { 6 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document); 7 | }; 8 | -------------------------------------------------------------------------------- /bookdown.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Bookdown" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | The bookdown package makes it easy to create books with R Markdown and RStudio. These can be easily published online and in various formats: HTML, PDF, ePub, and Kindle. Read about bookdown and see hundreds of online books written with it at [bookdown.org](https://bookdown.org/). 15 | 16 | Once you are ready to write your own book, read the [online documentation](https://bookdown.org/yihui/bookdown/). 17 | 18 | Examples: 19 | 20 | * The [bookdown.org](https://bookdown.org/) website has hundreds of examples. 21 | * We have a time-series book using it: [Applied Time-Series Analysis](https://nwfsc-timeseries.github.io/atsa-labs/) 22 | 23 | ## Download the template 24 | 25 | Download a zip file of the [bookdown-demo](https://github.com/RVerse-Tutorials/bookdown-demo) repository. You can use the 'download zip file' button on the GitHub repository or you can navigate to your 'RWorkflow' folder in RStudio and click 'More' in the Files panel and select 'Set as working directory'. Then issue these commands. 26 | 27 | ``` 28 | library(RWorkflowsetup) 29 | download.repo("bookdown-demo") 30 | ``` 31 | 32 | *INCOIS participants: You will find a copy of the repository in the RWorkflow directory that you copied from the thumb drive.* 33 | 34 | This is a copy of the [original bookdown-demo](https://github.com/rstudio/bookdown-demo) by Yihui Xie, the creator of the bookdown package, with a few changes so it works immediately with GitHub. 35 | 36 | ## Build the book 37 | 38 | 1. Open RStudio 39 | 2. Click the project button in top right and select 'New Project'. 40 | 3. Click 'Existing Directory' and choose your 'bookdown-demo' folder. 41 | 4. Click the Build tab and click 'Build book' 42 | 43 | Your book should appear. 44 | 45 | ## Post and online version of your book via GitHub 46 | 47 | You can host your book many places. To do so on GitHub, do the following. 48 | 49 | 1. Make your bookdown-demo folder into a repository. 50 | - Open GitHub Desktop, click 'File > New Repository' 51 | - Type `bookdown-demo` as the name and `\RWorkflow` as the local path. This assumes that the bookdown-demo folder is in the RWorkflow directory. If not, replace the path with the directory where you put the bookdown-demo folder. 52 | 2. Publish the bookdown-demo folder to GitHub. Click the Publish button in GitHub Desktop. 53 | 3. Open the repository on GitHub. 54 | - Click Settings, and scroll down to `GitHub Pages`. Change the source to `master branch/docs` folder and click save. 55 | 4. Your book should appear at `https://.github.io/bookdown-demo/` in a few minutes. 56 | 57 | -------------------------------------------------------------------------------- /_site.yml: -------------------------------------------------------------------------------- 1 | name: rworkflow-workshop 2 | output_dir: '.' 3 | navbar: 4 | title: RWorkflow 5 | left: 6 | - text: Set-up 7 | icon: fa-clone 8 | href: set-up.html 9 | - text: Workshop Weekly Notes 10 | icon: fa-calendar 11 | menu: 12 | - text: Week 1 RStudio + Version Control 13 | icon: fa-cogs 14 | href: week1-rstudio.html 15 | - text: Week 2 More Git + Code Organization 16 | icon: fa-code 17 | href: week2-coding.html 18 | - text: Week 3 R Markdown 19 | icon: fa-file 20 | href: week3-RMarkdown.html 21 | - text: Week 4 R Packages 22 | icon: fa-archive 23 | href: week4-packages.html 24 | - text: Week 5 Roxygen 25 | icon: fa-question-circle 26 | href: week5-roxygen.html 27 | - text: Week 6 More Packages 28 | icon: fa-folder 29 | href: week6-more-packages.html 30 | - text: Week 7 More Git 31 | icon: fa-git 32 | href: week7-more-git.html 33 | - text: Week 8 ggplot2 34 | icon: fa-image 35 | href: week8-ggplot2.html 36 | - text: Week 9 tidyverse 37 | icon: fa-broom 38 | href: week9-data-wrangling.html 39 | - text: Git 40 | icon: fa-git 41 | menu: 42 | - text: Intro to Git + GitHub/Lab 43 | icon: fa-cogs 44 | href: intro-git.html 45 | - text: More Git + GitHub 46 | icon: fa-github 47 | href: more-git.html 48 | - text: GitLab to GitHub 49 | icon: fa-truck-moving 50 | href: gitlab-to-github.html 51 | - text: Websites with GitHub 52 | icon: fa-chrome 53 | href: websites.html 54 | - text: Dynamic Websites with Jekyll and GitHub 55 | icon: fa-sitemap 56 | href: jekyll.html 57 | - text: RMarkdown 58 | icon: fa-file 59 | menu: 60 | - text: R Markdown for Reports 61 | icon: fa-file 62 | href: week3-RMarkdown.html 63 | - text: Bookdown 64 | icon: fa-book 65 | href: bookdown.html 66 | - text: R Packages 67 | icon: fa-archive 68 | menu: 69 | - text: R Packaging with RStudio 70 | icon: fa-archive 71 | href: week4-packages.html 72 | - text: Roxygen documentation 73 | icon: fa-question-circle 74 | href: week5-roxygen.html 75 | - text: Shiny GUIs 76 | icon: fa-gamepad 77 | href: shiny.html 78 | - text: More 79 | menu: 80 | - text: Tutorials 81 | href: links.html 82 | right: 83 | - text: Repo 84 | icon: fa-github 85 | href: https://github.com/RVerse-Tutorials/RWorkflow-NWFSC-2020 86 | - text: Search 87 | href: search.html 88 | 89 | output: 90 | html_document: 91 | theme: readable 92 | toc_depth: 2 93 | toc_float: 94 | collapsed: no 95 | highlight: textmate 96 | css: styles.css 97 | lib_dir: site_libs 98 | self_contained: no 99 | include: 100 | in_header: header.html 101 | in_footer: footer.html 102 | 103 | -------------------------------------------------------------------------------- /index.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Practical R Workflow for Scientists Summer 2020" 3 | --- 4 | 5 | 6 | 7 | These short sessions (45min to 1hr) will be focused on tools and practices for NMFS scientists to help you be **faster, more efficient and organized** in your coding and in merging reports with code. The focus of these workshops is practical skills and tools. Each session will be stand-alone. While the sessions will be introductory, I will give you links to my GitHub repositories that illustrate more complex examples (and that you can copy and build on). 8 | 9 | **Target audience**: You already code in R, maybe use RStudio too, but want to learn some tips about being more efficient from a seasoned NWFSC R programmer who does the kind of coding and work that you do. 10 | 11 | **About me**: I am a modeler/applied mathematician and I am immersed in R. I develop R packages for public use. I teach time-series analysis at the University of Washington (using R) and I teach workshops on R and reproducible research. 12 | 13 | ## Topics 14 | 15 | * [Week 1](week1-rstudio.html). Introduction to workflow using RStudio and Git/GitHub/GitLab [Video](https://www.youtube.com/watch?v=HxIpxVdQsDs) 16 | 17 | * [Week 2](week2-coding.html). More Git/GitHub/GitLab + Basic coding practices for reproducible and extendible code [Video](https://www.youtube.com/watch?v=k0P3e39qcA4) 18 | 19 | * [Week 3](week3-RMarkdown.html). Rmarkdown for reports: how to do big tables and export formats for Word docs [Video](https://www.youtube.com/watch?v=IGc2cgMFoPs) 20 | 21 | * [Week 4](week4-packages.html). Part 1. Organizing your R code into a package [Video](https://youtu.be/6d62KvS5v7Q) 22 | 23 | * [Week 5](week5-roxygen.html). Part 2. Documenting your code and data with Roxygen [Video](https://youtu.be/zHPSbhGtkz4) 24 | 25 | *Unfortunately at about 40min in, I managed to corrupt my R packages and could not demo any more so covered the material verbally. The problem demonstrates why I try to have few dependencies in my packages! One of the dependencies in my* **SardineForecast** *package had an install problem and corrupted the* **pkgload** *package.* 26 | 27 | * [Week 6](week6-more-packages.html). Part 3. Vignettes and plot/print methods for your package. [Video](https://youtu.be/O4rojT7aeb0) 28 | 29 | * [Week 7](week7-more-git.html). More Git. Merge conflicts, branches, and reverting changes. [Video](https://youtu.be/ZoB3dsZId9U ) 30 | 31 | * [Week 8](week8-ggplot2.html). Introduction to plotting with ggplot. [Video](https://youtu.be/odCam8JxvKI) 32 | 33 | * [Week 9](week9-data-wrangling.html). Introduction to Tidyverse verbs. 34 | 35 | 45 | 46 |
47 | 48 |
49 | NWFSC Math Bio Program 50 |
-------------------------------------------------------------------------------- /jekyll.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Jekyll Websites" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | Jekyll is another simple and popular way to make websites. There are many templates on GitHub that you can copy (fork) to make your own website. 15 | 16 | 17 | # jekyll-simple-blog 18 | 19 | This code is from [M Koehnke](http://mkoehnke.github.io). Per M Koehnke: This is an anonymized version of [Chris Eidhof's](http://github.com/chriseidhof) brilliant [blog theme](http://github.com/chriseidhof/chris.eidhof.nl) converted from Cactus to Jekyll. 20 | 21 | A live demo can be found [here](http://rverse-tutorials.github.io/jekyll-simple-blog/). 22 | 23 | Go to the [RVerse-Tutorials\jekyll-simple-blog](https://github.com/RVerse-Tutorials/jekyll-simple-blog) repository and click the Fork button in the upper right. You will need to be logged into your GitHub account. Then open RStudio and create a new project from that repository. This creates a copy of jekyll-simple-blog that is linked to the copy of the repository that you makde in your GitHub account. 24 | 25 | [Watch a video of this step](https://youtu.be/xeeKrGuaFRg) 26 | 27 | *INCOIS participants: You will find a copy of the repository in the RWorkflow directory that you copied from the thumb drive. However, without internet you won't be able to build your jekyll website.* 28 | 29 | ## Making the blog live 30 | 31 | * Go to settings of your jekyll-simple-blog GitHub repository and set Github Pages source as master. 32 | * Your new site should be ready at https://yourusername.github.io/jekyll-simple-blog/ . Note it can take awhile (5-10 min) for the website to appear and for changes to appear. 33 | * If you change the name of your repository (meaning change it from jekyll-simple-blog to something else), **change the baseurl in `_config.yml`** 34 | 35 | ## Making changes 36 | 37 | * Edit posts in `_posts` 38 | * Add posts in `_posts` 39 | * Upload the changes to GitHub via GitHub Desktop or Git in RStudio. 40 | 41 | # simple-cv 42 | 43 | This is a super simple online resume forked from [http://webjeda.com/online-cv/](http://webjeda.com/online-cv/). [Eli Holmes](https://eeholmes.github.io/) simplified Webjeda's design to make it more suitable for a simple flat resume and make it printable. 44 | 45 | ## Installation 46 | * Fork the repository https://github.com/RVerse-Tutorials/simple-cv 47 | * Go to settings of your repository and set Github Pages source as master. 48 | * Your new site should be ready at https://username.github.io/simple-cv/ 49 | * If you change the name of your repository, change the baseurl in `_config.yml` 50 | 51 | ## Enter your data 52 | * Edit `_config.yml` with your name, education and summary. The summary will appear in About Me. 53 | * Edit `_data\experiences.yml` with your work experience. 54 | * Edit `_data\coursework.yml` with your coursework. 55 | * Edit `_data\skills.yml` with your skills. 56 | * Add your picture to `assets\images\` and put the file name in `_config.yml` in `pic:` 57 | 58 | -------------------------------------------------------------------------------- /more-git.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "More Git" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 15 | library(kableExtra) 16 | dt <- data.frame("Compartmentalized", "Documented", "Extendible", "Reproducible", "Robust") 17 | kable(dt, col.names=NULL) %>% 18 | kable_styling(full_width = TRUE) %>% 19 | row_spec(1, bold = FALSE, color = "white", background = "blue") %>% 20 | column_spec(column = 1:5, width = "20%") 21 | ``` 22 | 23 | 24 | # Overview 25 | 26 | Here I will cover a few more come Git tasks and show some straight-forward ways to do these tasks 27 | 28 | * How to clone someone else's GitHub or GitLab repository 29 | * How to clone your own repository--when you want to make a copy and use that as a template for something new. 30 | 31 | 36 | 37 | ## Downloading other people's repositories 38 | 39 | There are two easy ways to do this. Use the one that seems more logical to you. 40 | 41 | Method 1. 42 | 43 | 1. In a browser, go to the GitHub (or GitLab) repository you want to copy. 44 | 2. Copy its url. 45 | 3. Open GitHub or GitLab. 46 | 4. If using GitHub, click the `+` in top right and click `import repository`. Paste in the url and give your repo a name. 47 | 4. If using GitLab, click `New Project` on right, then `Import Repository` tab, then click `Repo by URL`. Paste in url and give repo a name. 48 | 5. Open RStudio and click the project tab in the top right and select, `New Project`. Then select `Version Control` and paste in the url of **your** repository's url. For example, `https://github.com//Test` 49 | 6. Add the new repo to GitHub Desktop. Open GitHub Desktop, select File>Add Local Repository and navigate to the folder with the new repository. 50 | 51 | Method 2. 52 | 53 | Steps 1-4 are the same but you can swap step 5 and 6. 54 | 55 | 5. Open GitHub Desktop. Select File>Clone Repository. Paste in the repository url that you are copying and tell it where to save the repository. 56 | 5. Open RStudio and click the project tab in the top right and select, `New Project`. Then select `Existing Directory` and navigate to the directory where you 57 | just saved the repo. 58 | 59 | You can also clone someone elses repo directly into RStudio or GitHub Desktop and then "Publish" to GitHub or GitLab. I am not going to show that but I show that on this [page](Git-RStudio.html). For GitLab, it will require issuing Git commands from a terminal. Note, in my experience, method 1 or 2 above is the way to avoid Git-misery as a Git beginner. 60 | 61 | ## Making a copy of your own repository 62 | 63 | Let say you want to make a copy of a repository and use it as a template to make something else. And you don't want the history! 64 | 65 | 1. Make a blank repo on GitHub or GitLab (add that Readme file) 66 | 2. Pull that down to your computer 67 | 3. Copy the repo you want to copy into the new repo folder but **do not copy the .git folder**. Remember the `.git` folder is hidden. 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /links.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Resources" 3 | --- 4 | 5 | ## Never worked with R? 6 | 7 | If you have never worked with R, you can get a basic familiarity by going through [this free tutorial](https://www.datacamp.com/courses/free-introduction-to-r). Takes about 4 hours. 8 | 9 | You can also learn R straight from within R using the [swirl package](https://swirlstats.com/). This doesn't require internet access except to install the package. 10 | 11 | Here is another basic R introduction from [ComputerWorld](https://www.computerworld.com/article/2497143/business-intelligence/business-intelligence-beginner-s-guide-to-r-introduction.html). 12 | 13 | The book that I recommend for scientists who have never worked with R is [The R Student Companion](https://www.amazon.com/R-Student-Companion-Brian-Dennis-ebook/dp/B009AIU07G) by Brian Dennis. It'll get you up to speed with the type of programming that scientists do with R. I think you'd be fine just renting it for a month and getting through as much as you can in a month. After a few chapters, you'll know your way around R and, more importantly, how to program with functions. Then you'll be ready for something else. 14 | 15 | Once you work through that, [R for Data Science](https://r4ds.had.co.nz/) by Garrett Grolemund 16 | and Hadley Wickham is very good for what the sort of work we do. 17 | 18 | # R Markdown 19 | 20 | * [RStudio's lessons](https://rmarkdown.rstudio.com/lesson-1.html) 21 | 22 | # Git and GitHub 23 | 24 | * [Happy Git with R](https://happygitwithr.com/) Detail on Git and GitHub, but accessible. 25 | 26 | # R packages that I use all the time 27 | 28 | These are some basic packages that I use all the time. This does not include the analysis packages that I use. 29 | 30 | * [Tidyverse](https://www.tidyverse.org/) packages. I am not a fan of all the tidyverse package and I dislike piping (because it is horribly slow and I need fast for simulation work), but I try to keep up with the ideas in the "tidyverse" and I try to adopt tidyverse style. In particular, I try to format all my data into tidy format. 31 | * ggplot2: I find ggplot to be hard to learn and too confining, but I use it all the time because it makes plots with many layers so much easier and it makes plot layout easier. I don't like it for my publication quality plots (just too much hassle to get the look I want) but I use it constantly for mock-ups. 32 | * stringr: I work with strings all the time so I always need this. 33 | * dplyr: When I need to go from wide-form to short-form layout, I like it. Definitely I think it is good to inform yourself as to what it does. 34 | * XML: I use it to scrape data from online tables using the `readHTMLTable()` function. I think xml2 in the tidyverse might do the same thing. 35 | * here: This is a handy utility package, along with `file.path()` allows you to make file paths to the base of the project. If you find yourself doing `setwd()` anywhere in your code, you'll want to use `here()` to avoid that because doing that breaks your code for anyone else. 36 | * xtable: Handy for making complex tables. 37 | 38 | # Other Reproducible Research Short-Courses 39 | 40 | * [Reproductible Research 2017](https://eriqande.github.io/rep-res-eeb-2017/index.html) Source for some of the introductory material. 41 | 42 | # Making simple websites 43 | 44 | * [Another tutorial] (https://jules32.github.io/rmarkdown-website-tutorial/index.html) with more examples and slightly more complicated websites. 45 | 46 | # Jekyll 47 | 48 | * [Installing Jekyll on Mac OS](https://learn.cloudcannon.com/jekyll/install-jekyll-on-os-x/) 49 | * [Jekyll build](https://learn.cloudcannon.com/jekyll/running-jekyll/) 50 | 51 | # Jekyll Templates 52 | 53 | * [Hugo Academic](https://sourcethemes.com/academic/) Popular Jekyll template in academia. 54 | -------------------------------------------------------------------------------- /site_libs/bootstrap-3.3.5/shim/respond.min.js: -------------------------------------------------------------------------------- 1 | /*! Respond.js v1.4.2: min/max-width media query polyfill * Copyright 2013 Scott Jehl 2 | * Licensed under https://github.com/scottjehl/Respond/blob/master/LICENSE-MIT 3 | * */ 4 | 5 | // Only run this code in IE 8 6 | if (!!window.navigator.userAgent.match("MSIE 8")) { 7 | !function(a){"use strict";a.matchMedia=a.matchMedia||function(a){var b,c=a.documentElement,d=c.firstElementChild||c.firstChild,e=a.createElement("body"),f=a.createElement("div");return f.id="mq-test-1",f.style.cssText="position:absolute;top:-100em",e.style.background="none",e.appendChild(f),function(a){return f.innerHTML='­',c.insertBefore(e,d),b=42===f.offsetWidth,c.removeChild(e),{matches:b,media:a}}}(a.document)}(this),function(a){"use strict";function b(){u(!0)}var c={};a.respond=c,c.update=function(){};var d=[],e=function(){var b=!1;try{b=new a.XMLHttpRequest}catch(c){b=new a.ActiveXObject("Microsoft.XMLHTTP")}return function(){return b}}(),f=function(a,b){var c=e();c&&(c.open("GET",a,!0),c.onreadystatechange=function(){4!==c.readyState||200!==c.status&&304!==c.status||b(c.responseText)},4!==c.readyState&&c.send(null))};if(c.ajax=f,c.queue=d,c.regex={media:/@media[^\{]+\{([^\{\}]*\{[^\}\{]*\})+/gi,keyframes:/@(?:\-(?:o|moz|webkit)\-)?keyframes[^\{]+\{(?:[^\{\}]*\{[^\}\{]*\})+[^\}]*\}/gi,urls:/(url\()['"]?([^\/\)'"][^:\)'"]+)['"]?(\))/g,findStyles:/@media *([^\{]+)\{([\S\s]+?)$/,only:/(only\s+)?([a-zA-Z]+)\s?/,minw:/\([\s]*min\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/,maxw:/\([\s]*max\-width\s*:[\s]*([\s]*[0-9\.]+)(px|em)[\s]*\)/},c.mediaQueriesSupported=a.matchMedia&&null!==a.matchMedia("only all")&&a.matchMedia("only all").matches,!c.mediaQueriesSupported){var g,h,i,j=a.document,k=j.documentElement,l=[],m=[],n=[],o={},p=30,q=j.getElementsByTagName("head")[0]||k,r=j.getElementsByTagName("base")[0],s=q.getElementsByTagName("link"),t=function(){var a,b=j.createElement("div"),c=j.body,d=k.style.fontSize,e=c&&c.style.fontSize,f=!1;return b.style.cssText="position:absolute;font-size:1em;width:1em",c||(c=f=j.createElement("body"),c.style.background="none"),k.style.fontSize="100%",c.style.fontSize="100%",c.appendChild(b),f&&k.insertBefore(c,k.firstChild),a=b.offsetWidth,f?k.removeChild(c):c.removeChild(b),k.style.fontSize=d,e&&(c.style.fontSize=e),a=i=parseFloat(a)},u=function(b){var c="clientWidth",d=k[c],e="CSS1Compat"===j.compatMode&&d||j.body[c]||d,f={},o=s[s.length-1],r=(new Date).getTime();if(b&&g&&p>r-g)return a.clearTimeout(h),h=a.setTimeout(u,p),void 0;g=r;for(var v in l)if(l.hasOwnProperty(v)){var w=l[v],x=w.minw,y=w.maxw,z=null===x,A=null===y,B="em";x&&(x=parseFloat(x)*(x.indexOf(B)>-1?i||t():1)),y&&(y=parseFloat(y)*(y.indexOf(B)>-1?i||t():1)),w.hasquery&&(z&&A||!(z||e>=x)||!(A||y>=e))||(f[w.media]||(f[w.media]=[]),f[w.media].push(m[w.rules]))}for(var C in n)n.hasOwnProperty(C)&&n[C]&&n[C].parentNode===q&&q.removeChild(n[C]);n.length=0;for(var D in f)if(f.hasOwnProperty(D)){var E=j.createElement("style"),F=f[D].join("\n");E.type="text/css",E.media=D,q.insertBefore(E,o.nextSibling),E.styleSheet?E.styleSheet.cssText=F:E.appendChild(j.createTextNode(F)),n.push(E)}},v=function(a,b,d){var e=a.replace(c.regex.keyframes,"").match(c.regex.media),f=e&&e.length||0;b=b.substring(0,b.lastIndexOf("/"));var g=function(a){return a.replace(c.regex.urls,"$1"+b+"$2$3")},h=!f&&d;b.length&&(b+="/"),h&&(f=1);for(var i=0;f>i;i++){var j,k,n,o;h?(j=d,m.push(g(a))):(j=e[i].match(c.regex.findStyles)&&RegExp.$1,m.push(RegExp.$2&&g(RegExp.$2))),n=j.split(","),o=n.length;for(var p=0;o>p;p++)k=n[p],l.push({media:k.split("(")[0].match(c.regex.only)&&RegExp.$2||"all",rules:m.length-1,hasquery:k.indexOf("(")>-1,minw:k.match(c.regex.minw)&&parseFloat(RegExp.$1)+(RegExp.$2||""),maxw:k.match(c.regex.maxw)&&parseFloat(RegExp.$1)+(RegExp.$2||"")})}u()},w=function(){if(d.length){var b=d.shift();f(b.href,function(c){v(c,b.href,b.media),o[b.href]=!0,a.setTimeout(function(){w()},0)})}},x=function(){for(var b=0;b 7 | * adapted by Ruben Arslan to activate parent tabs too 8 | * http://www.aidanlister.com/2014/03/persisting-the-tab-state-in-bootstrap/ 9 | */ 10 | (function($) { 11 | "use strict"; 12 | $.fn.rmarkdownStickyTabs = function() { 13 | var context = this; 14 | // Show the tab corresponding with the hash in the URL, or the first tab 15 | var showStuffFromHash = function() { 16 | var hash = window.location.hash; 17 | var selector = hash ? 'a[href="' + hash + '"]' : 'li.active > a'; 18 | var $selector = $(selector, context); 19 | if($selector.data('toggle') === "tab") { 20 | $selector.tab('show'); 21 | // walk up the ancestors of this element, show any hidden tabs 22 | $selector.parents('.section.tabset').each(function(i, elm) { 23 | var link = $('a[href="#' + $(elm).attr('id') + '"]'); 24 | if(link.data('toggle') === "tab") { 25 | link.tab("show"); 26 | } 27 | }); 28 | } 29 | }; 30 | 31 | 32 | // Set the correct tab when the page loads 33 | showStuffFromHash(context); 34 | 35 | // Set the correct tab when a user uses their back/forward button 36 | $(window).on('hashchange', function() { 37 | showStuffFromHash(context); 38 | }); 39 | 40 | // Change the URL when tabs are clicked 41 | $('a', context).on('click', function(e) { 42 | history.pushState(null, null, this.href); 43 | showStuffFromHash(context); 44 | }); 45 | 46 | return this; 47 | }; 48 | }(jQuery)); 49 | 50 | window.buildTabsets = function(tocID) { 51 | 52 | // build a tabset from a section div with the .tabset class 53 | function buildTabset(tabset) { 54 | 55 | // check for fade and pills options 56 | var fade = tabset.hasClass("tabset-fade"); 57 | var pills = tabset.hasClass("tabset-pills"); 58 | var navClass = pills ? "nav-pills" : "nav-tabs"; 59 | 60 | // determine the heading level of the tabset and tabs 61 | var match = tabset.attr('class').match(/level(\d) /); 62 | if (match === null) 63 | return; 64 | var tabsetLevel = Number(match[1]); 65 | var tabLevel = tabsetLevel + 1; 66 | 67 | // find all subheadings immediately below 68 | var tabs = tabset.find("div.section.level" + tabLevel); 69 | if (!tabs.length) 70 | return; 71 | 72 | // create tablist and tab-content elements 73 | var tabList = $(''); 74 | $(tabs[0]).before(tabList); 75 | var tabContent = $('
'); 76 | $(tabs[0]).before(tabContent); 77 | 78 | // build the tabset 79 | var activeTab = 0; 80 | tabs.each(function(i) { 81 | 82 | // get the tab div 83 | var tab = $(tabs[i]); 84 | 85 | // get the id then sanitize it for use with bootstrap tabs 86 | var id = tab.attr('id'); 87 | 88 | // see if this is marked as the active tab 89 | if (tab.hasClass('active')) 90 | activeTab = i; 91 | 92 | // remove any table of contents entries associated with 93 | // this ID (since we'll be removing the heading element) 94 | $("div#" + tocID + " li a[href='#" + id + "']").parent().remove(); 95 | 96 | // sanitize the id for use with bootstrap tabs 97 | id = id.replace(/[.\/?&!#<>]/g, '').replace(/\s/g, '_'); 98 | tab.attr('id', id); 99 | 100 | // get the heading element within it, grab it's text, then remove it 101 | var heading = tab.find('h' + tabLevel + ':first'); 102 | var headingText = heading.html(); 103 | heading.remove(); 104 | 105 | // build and append the tab list item 106 | var a = $('' + headingText + ''); 107 | a.attr('href', '#' + id); 108 | a.attr('aria-controls', id); 109 | var li = $('
  • '); 110 | li.append(a); 111 | tabList.append(li); 112 | 113 | // set it's attributes 114 | tab.attr('role', 'tabpanel'); 115 | tab.addClass('tab-pane'); 116 | tab.addClass('tabbed-pane'); 117 | if (fade) 118 | tab.addClass('fade'); 119 | 120 | // move it into the tab content div 121 | tab.detach().appendTo(tabContent); 122 | }); 123 | 124 | // set active tab 125 | $(tabList.children('li')[activeTab]).addClass('active'); 126 | var active = $(tabContent.children('div.section')[activeTab]); 127 | active.addClass('active'); 128 | if (fade) 129 | active.addClass('in'); 130 | 131 | if (tabset.hasClass("tabset-sticky")) 132 | tabset.rmarkdownStickyTabs(); 133 | } 134 | 135 | // convert section divs with the .tabset class to tabsets 136 | var tabsets = $("div.section.tabset"); 137 | tabsets.each(function(i) { 138 | buildTabset($(tabsets[i])); 139 | }); 140 | }; 141 | 142 | -------------------------------------------------------------------------------- /gitlab-to-github.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Migrating from GitLab to GitHub" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 15 | library(kableExtra) 16 | dt <- data.frame("Compartmentalized", "Documented", "Extendible", "Reproducible", "Robust") 17 | kable(dt, col.names=NULL) %>% 18 | kable_styling(full_width = TRUE) %>% 19 | row_spec(1, bold = FALSE, color = "white", background = "blue") %>% 20 | column_spec(column = 1:5, width = "20%") 21 | ``` 22 | 23 | 24 | # GitLab to GitHub Migration 25 | 26 | This if for migrating repos from one INTERNAL GitLab server to another. This is geared to RStudio users. 27 | 28 | Although this is long, that is because I went into every single step in detail. It's actually quite easy. 29 | 30 | 1. Make the blank repo on 31 | 2. In RStudio, update the .git/config file with the new github url 32 | 3. Click Push 33 | 34 | Let's give the URL for the internal GitHub and GitLab the following names: 35 | 36 | * Internal GitHub URL: https://github.XYZ.local 37 | * Internal GitLab URL: https://gitlab.XYZ.local 38 | 39 | Obviously replace with the real URLs. It won't be anything like that. 40 | 41 | ## Initial set-up 42 | 43 | 1. VPN into into your local network. 44 | 2. Go to https://github.XYZ.local and login. 45 | 3. In another tab on your browser, login to https://gitlab.XYZ.local 46 | 47 | ## Make a blank repo on GitHub 48 | 49 | * Let's say my repo on GitLab is TestPackage1. 50 | 1. Look in upper right for the + sign. Click that and click New Repository. 51 | 2. Give the new repo the same name as the GitLab repo. So I will call it TestPackage on github.nwfsc2.noaa.gov 52 | 3. Click Create Repository. Private/Public doesn't matter. DO NOT click the boxes to add a README or .gitignore! 53 | 4. Ignore the page that comes up saying 'Quick Set-up' etc. Just stop there and go to the next step below. 54 | 55 | ## Leave the browser and go to RStudio. 56 | 57 | 1. Open up the project with the files that are in your GitLab repo. So I open my TestPackage project in RStudio. 58 | * Don't have those files locally? See instructions below to get those to get a copy locally and as a project in RStudio. 59 | 2. In RStudio, look for the 'More' cog in the Files pane, Click that and make sure is shows 'Show Hidden Files' 60 | 3. Open the .git folder in the Files pane. Click on 'config' to open that file. 61 | 4. Look for the line that says 'url = https://gitlab.XYZ.local 62 | 5. Change https://gitlab.XYZ.local to https://github.XYZ.local. Everything else stays the same. 63 | 64 | So for me that line changes from 65 | 66 | url = https://gitlab.XYZ.local/eholmes/TestPackage to 67 | 68 | url = https://github.XYZ.local/eholmes/TestPackage 69 | 70 | 6. Save. 71 | 7. Click the Git tab (just above the File pane), and click the upward Green arrow. 72 | 8. It'll ask you for a password the first time you do this. You'll see a pop-up window, but it won't tell you that it is done. 73 | 74 | ## Back to the GitHub server 75 | 76 | * Go back to the browser to https://github.XYZ.local and refresh the page. Voila your files are there. 77 | 78 | ## Troubleshooting 79 | 80 | ### Don't have your GitLab repo on your computer? 81 | 1. Copy the url of the repo. So like https://gitlab.XYZ.local/eholmes/TestPackage 82 | 2. Open RStudio and click File > New Project > Version Control > Git and paste the URL into Repository URL. 83 | * Note give some thought to where you keep repos on your local computer. I keep all of mine in one folder called GitHub in my Documents folder. You might lose track of them if you don't keep them in the same spot. 84 | 3. Click Create Project 85 | 86 | ### You have the GitLab repo on your computer but it is not an RStudio project. 87 | 88 | 1. Open RStudio and click File > New Project > Existing Folder > Git and paste the URL into Repository URL. 89 | 2. Click Create Project > Existing Directory then navigate to the folder with the repo on your computer. 90 | 91 | ### When I click Push, I get an error that RStudio doesn't know how to get my GitHub credentials. Sorry, that's a pain. You need to tell RStudio how to get that info. 92 | 93 | * https://rverse-tutorials.github.io/RWorkflow-NWFSC-2020/set-up.html#Set_up_RStudio_to_use_Git 94 | 95 | ### I got the error 'Repo not found' when I clicked push 96 | 97 | * Either you misspelled the url in the .git/config file or you forgot to make the repo on https://github.XYZ.local 98 | 99 | ### I got an error saying cannot merge because of conflicting histories (or something like that) 100 | 101 | * You clicked the boxes and created a ReadME or .gitignore file when you created the repo on github.nwfsc2.noaa.gov. 102 | 103 | 1. Go back to the repo on https://github.XYZ.local. 104 | 2. Click Settings (nav bar just above the big green Code button) 105 | 3. Scroll down and delete the repo 106 | 4. Create it again and this time don't click one of those check boxes that makes a Readme or .gitignore file 107 | 108 | ### I did what you said but when I go to https://github.XYZ.local, I don't see the files. It still shows the Quick Set-up instructions. 109 | 110 | * Refresh the page 111 | 112 | ### More help on working with GitHub is here 113 | 114 | * https://rverse-tutorials.github.io/RWorkflow-NWFSC-2020/week1-rstudio.html#Git_(GitHubGitLab) 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /site_libs/lightable-0.0.1/lightable.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * lightable v0.0.1 3 | * Copyright 2020 Hao Zhu 4 | * Licensed under MIT (https://github.com/haozhu233/kableExtra/blob/master/LICENSE) 5 | */ 6 | 7 | .lightable-minimal { 8 | border-collapse: separate; 9 | border-spacing: 16px 1px; 10 | width: 100%; 11 | margin-bottom: 10px; 12 | } 13 | 14 | .lightable-minimal td { 15 | margin-left: 5px; 16 | margin-right: 5px; 17 | } 18 | 19 | .lightable-minimal th { 20 | margin-left: 5px; 21 | margin-right: 5px; 22 | } 23 | 24 | .lightable-minimal thead tr:last-child th { 25 | border-bottom: 2px solid #00000050; 26 | empty-cells: hide; 27 | 28 | } 29 | 30 | .lightable-minimal tbody tr:first-child td { 31 | padding-top: 0.5em; 32 | } 33 | 34 | .lightable-minimal.lightable-hover tbody tr:hover { 35 | background-color: #f5f5f5; 36 | } 37 | 38 | .lightable-minimal.lightable-striped tbody tr:nth-child(even) { 39 | background-color: #f5f5f5; 40 | } 41 | 42 | .lightable-classic { 43 | border-top: 0.16em solid #111111; 44 | border-bottom: 0.16em solid #111111; 45 | width: 100%; 46 | margin-bottom: 10px; 47 | margin: 10px 5px; 48 | } 49 | 50 | .lightable-classic tfoot tr td { 51 | border: 0; 52 | } 53 | 54 | .lightable-classic tfoot tr:first-child td { 55 | border-top: 0.14em solid #111111; 56 | } 57 | 58 | .lightable-classic caption { 59 | color: #222222; 60 | } 61 | 62 | .lightable-classic td { 63 | padding-left: 5px; 64 | padding-right: 5px; 65 | color: #222222; 66 | } 67 | 68 | .lightable-classic th { 69 | padding-left: 5px; 70 | padding-right: 5px; 71 | font-weight: normal; 72 | color: #222222; 73 | } 74 | 75 | .lightable-classic thead tr:last-child th { 76 | border-bottom: 0.10em solid #111111; 77 | } 78 | 79 | .lightable-classic.lightable-hover tbody tr:hover { 80 | background-color: #F9EEC1; 81 | } 82 | 83 | .lightable-classic.lightable-striped tbody tr:nth-child(even) { 84 | background-color: #f5f5f5; 85 | } 86 | 87 | .lightable-classic-2 { 88 | border-top: 3px double #111111; 89 | border-bottom: 3px double #111111; 90 | width: 100%; 91 | margin-bottom: 10px; 92 | } 93 | 94 | .lightable-classic-2 tfoot tr td { 95 | border: 0; 96 | } 97 | 98 | .lightable-classic-2 tfoot tr:first-child td { 99 | border-top: 3px double #111111; 100 | } 101 | 102 | .lightable-classic-2 caption { 103 | color: #222222; 104 | } 105 | 106 | .lightable-classic-2 td { 107 | padding-left: 5px; 108 | padding-right: 5px; 109 | color: #222222; 110 | } 111 | 112 | .lightable-classic-2 th { 113 | padding-left: 5px; 114 | padding-right: 5px; 115 | font-weight: normal; 116 | color: #222222; 117 | } 118 | 119 | .lightable-classic-2 tbody tr:last-child td { 120 | border-bottom: 3px double #111111; 121 | } 122 | 123 | .lightable-classic-2 thead tr:last-child th { 124 | border-bottom: 1px solid #111111; 125 | } 126 | 127 | .lightable-classic-2.lightable-hover tbody tr:hover { 128 | background-color: #F9EEC1; 129 | } 130 | 131 | .lightable-classic-2.lightable-striped tbody tr:nth-child(even) { 132 | background-color: #f5f5f5; 133 | } 134 | 135 | .lightable-material { 136 | min-width: 100%; 137 | white-space: nowrap; 138 | table-layout: fixed; 139 | font-family: Roboto, sans-serif; 140 | border: 1px solid #EEE; 141 | border-collapse: collapse; 142 | margin-bottom: 10px; 143 | } 144 | 145 | .lightable-material tfoot tr td { 146 | border: 0; 147 | } 148 | 149 | .lightable-material tfoot tr:first-child td { 150 | border-top: 1px solid #EEE; 151 | } 152 | 153 | .lightable-material th { 154 | height: 56px; 155 | padding-left: 16px; 156 | padding-right: 16px; 157 | } 158 | 159 | .lightable-material td { 160 | height: 52px; 161 | padding-left: 16px; 162 | padding-right: 16px; 163 | border-top: 1px solid #eeeeee; 164 | } 165 | 166 | .lightable-material.lightable-hover tbody tr:hover { 167 | background-color: #f5f5f5; 168 | } 169 | 170 | .lightable-material.lightable-striped tbody tr:nth-child(even) { 171 | background-color: #f5f5f5; 172 | } 173 | 174 | .lightable-material.lightable-striped tbody td { 175 | border: 0; 176 | } 177 | 178 | .lightable-material.lightable-striped thead tr:last-child th { 179 | border-bottom: 1px solid #ddd; 180 | } 181 | 182 | .lightable-material-dark { 183 | min-width: 100%; 184 | white-space: nowrap; 185 | table-layout: fixed; 186 | font-family: Roboto, sans-serif; 187 | border: 1px solid #FFFFFF12; 188 | border-collapse: collapse; 189 | margin-bottom: 10px; 190 | background-color: #363640; 191 | } 192 | 193 | .lightable-material-dark tfoot tr td { 194 | border: 0; 195 | } 196 | 197 | .lightable-material-dark tfoot tr:first-child td { 198 | border-top: 1px solid #FFFFFF12; 199 | } 200 | 201 | .lightable-material-dark th { 202 | height: 56px; 203 | padding-left: 16px; 204 | padding-right: 16px; 205 | color: #FFFFFF60; 206 | } 207 | 208 | .lightable-material-dark td { 209 | height: 52px; 210 | padding-left: 16px; 211 | padding-right: 16px; 212 | color: #FFFFFF; 213 | border-top: 1px solid #FFFFFF12; 214 | } 215 | 216 | .lightable-material-dark.lightable-hover tbody tr:hover { 217 | background-color: #FFFFFF12; 218 | } 219 | 220 | .lightable-material-dark.lightable-striped tbody tr:nth-child(even) { 221 | background-color: #FFFFFF12; 222 | } 223 | 224 | .lightable-material-dark.lightable-striped tbody td { 225 | border: 0; 226 | } 227 | 228 | .lightable-material-dark.lightable-striped thead tr:last-child th { 229 | border-bottom: 1px solid #FFFFFF12; 230 | } 231 | 232 | .lightable-paper { 233 | width: 100%; 234 | margin-bottom: 10px; 235 | color: #444; 236 | } 237 | 238 | .lightable-paper tfoot tr td { 239 | border: 0; 240 | } 241 | 242 | .lightable-paper tfoot tr:first-child td { 243 | border-top: 1px solid #00000020; 244 | } 245 | 246 | .lightable-paper thead tr:last-child th { 247 | color: #666; 248 | vertical-align: bottom; 249 | border-bottom: 1px solid #00000020; 250 | line-height: 1.15em; 251 | padding: 10px 5px; 252 | } 253 | 254 | .lightable-paper td { 255 | vertical-align: middle; 256 | border-bottom: 1px solid #00000010; 257 | line-height: 1.15em; 258 | padding: 7px 5px; 259 | } 260 | 261 | .lightable-paper.lightable-hover tbody tr:hover { 262 | background-color: #F9EEC1; 263 | } 264 | 265 | .lightable-paper.lightable-striped tbody tr:nth-child(even) { 266 | background-color: #00000008; 267 | } 268 | 269 | .lightable-paper.lightable-striped tbody td { 270 | border: 0; 271 | } 272 | 273 | -------------------------------------------------------------------------------- /shiny.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Shiny Applications" 3 | output: 4 | html_document: 5 | toc: true 6 | --- 7 | 8 | ```{r setup, include=FALSE} 9 | knitr::opts_chunk$set(echo = TRUE) 10 | ``` 11 | 12 | [shiny applicatons](https://shiny.rstudio.com/) are a GUI (graphical user interface) that can run a R-based application. You can then post this online and it will run from an R server (not your computer). Users can run your application from the web without having to install R. In fact they can run from any browser, for example a smart phone. Alternatively, you can just have it in a package and provide it as a way for users to run analyses when they use your package from R. 13 | 14 | ## Fisheries examples 15 | 16 | Here are two example shiny apps that we have at the NWFSC. They are simple but are intended mainly to allow users to run standard analyses or explore data. shiny applications can be quite sophisticated and 'shiny'. Search online for 'shiny demos'. 17 | 18 | * [Fisheries Economics Data Explorer](https://dataexplorer.northwestscience.fisheries.noaa.gov/fisheye/NetRevExplorer/) 19 | - Proprietary data 20 | 21 | * [Steller Sea Lion Trend Estimation](https://dataexplorer.northwestscience.fisheries.noaa.gov/nwc/agTrend/) 22 | - Needed specialized add-on software 23 | 24 | The U.S. Geological Survey (a U.S. federal agency) also it active in developing tools to be used by the public and serves these on its [usgs-r.github.io](http://usgs-r.github.io/) organizational site. They have been active in using Shiny apps for data exploration. 25 | 26 | * [Lake Erie Fish Survey](https://lebs.shinyapps.io/western-basin/) - [code](https://github.com/taylorstewart/lebs-western-basin-app) 27 | * [toxEval](http://usgs-r.github.io/toxEval/index.html) 28 | 29 | ## Make your first shiny app 30 | 31 | 1. Install the shiny package. 32 | ``` 33 | install.packages("shiny") 34 | ``` 35 | 36 | 1. Click File > New > Shiny Web App... 37 | 2. Select a location to put the application folder. 38 | 3. Select "Multiple File". You can choose single file, but I will demo the separate case with a separate file for the interface code and 'workhorse' code. 39 | 4. Give you application a name. 40 | 4. When the files 'ui.R' and 'server.R' open, click 'Run App'. 41 | 42 | That's it. You made a shiny application. To stop the app, close the window or hit ESC at the command line in RStudio. 43 | 44 | ## ui.R file 45 | 46 | This is the code that specifies the graphical interface. 47 | 48 | ``` 49 | # Define UI for application that draws a histogram 50 | shinyUI(fluidPage( 51 | 52 | # Application title 53 | titlePanel("Old Faithful Geyser Data"), 54 | 55 | # Sidebar with a slider input for number of bins 56 | sidebarLayout( 57 | sidebarPanel( 58 | sliderInput("bins", 59 | "Number of bins:", 60 | min = 1, 61 | max = 50, 62 | value = 30) 63 | ), 64 | 65 | # Show a plot of the generated distribution 66 | mainPanel( 67 | plotOutput("distPlot") 68 | ) 69 | ) 70 | )) 71 | ``` 72 | 73 | ## server.R 74 | 75 | This part has the R code that does the analysis, makes plots, makes table, etc. 76 | 77 | ``` 78 | shinyServer(function(input, output) { 79 | 80 | output$distPlot <- renderPlot({ 81 | 82 | # generate bins based on input$bins from ui.R 83 | x <- faithful[, 2] 84 | bins <- seq(min(x), max(x), length.out = input$bins + 1) 85 | 86 | # draw the histogram with the specified number of bins 87 | hist(x, breaks = bins, col = 'darkgray', border = 'white') 88 | 89 | }) 90 | 91 | }) 92 | ``` 93 | 94 | ## What can shiny apps do and how can I copy that? 95 | 96 | Go to the [RStudio shiny gallery](https://shiny.rstudio.com/gallery/), scroll down to the "Start Simple" section and start there. Once you want to add some more sections to your app, look lower at the Widgets sections. The code for the examples is there. 97 | 98 | You'll also want to go through RStudio's [online tutorial](https://shiny.rstudio.com/tutorial/written-tutorial/lesson1/) for shiny apps. 99 | 100 | Development of anything past a fairly simple shiny app is quite time-consuming. This is a task that I outsource. 101 | 102 | ## Putting your application online 103 | 104 | NW Fisheries Science Center (where I work) has its own R Shiny Server because we has applications with proprietary data that cannot be put on non-NOAA server. In addition, many of our applications require specialized extra software for fitting Bayesian models. Thus our application need more than just R packages. 105 | 106 | However, if your application does not have these special constraints, you can host online for free with [http://www.shinyapps.io/](http://www.shinyapps.io/). 107 | 108 | Follow the instructions [here](https://shiny.rstudio.com/articles/shinyapps.html). In summary: 109 | 110 | 1. Sign up for an account at [http://www.shinyapps.io/](http://www.shinyapps.io/) 111 | 112 | 2. install the rsconnect package 113 | ``` 114 | install.packages("rsconnect") 115 | library(rsconnect) 116 | ``` 117 | 118 | 3. Login into your account at [http://www.shinyapps.io/](http://www.shinyapps.io/). Click on your user name in top right, and click 'Tokens' 119 | 120 | 4. A window should popup with code that looks like 121 | ``` 122 | rsconnect::setAccountInfo(name="", token="", secret="") 123 | ``` 124 | Click 'Copy to clipboard'. 125 | 126 | 5. Paste that code into the command line in R. 127 | 128 | 6. From R, click on the `ui.R` or `server.R` file. Click 'Run App'. You should see a 'Publish' button in the top right. Click that. Select 'shinyapps.io' and log into your account. 129 | 130 | 7. When your app opens, copy the url to the app. 131 | 132 | ## Adding a shiny app to your R package 133 | 134 | 1. In your DESCRIPTION file, add 'shiny' to the list of packages in the 'Imports:' line. 135 | 136 | 1. Create a folder called 'inst' in your package. 137 | 138 | 2. Create a folder called 'shiny' in that. 139 | 140 | 3. Within that folder, put your folder with all your application files. 'ui.R', 'server.R', any data files, any function files. 141 | 142 | 5. Add the following code to a files called `launchApp.R` to your R directory. Change "myapp" and "mypackage" to the right names. 143 | ``` 144 | #' @export 145 | launchApp <- function(x="myapp") { 146 | appDir <- system.file("shiny", "myapp", package = "mypackage") 147 | shiny::runApp(appDir, display.mode = "normal") 148 | } 149 | ``` 150 | Rebuild your package. If later you add more shiny apps, but their folder in the shiny directory too. You run them with `launchApp("mynewapp")`. 151 | 152 | 4. To run 153 | ``` 154 | library(mypackage) 155 | runIt("myapp") 156 | ``` 157 | Replace 'mypackage' and 'myapp' with the right names. 158 | 159 | 160 | -------------------------------------------------------------------------------- /week5-roxygen.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Week 5: Roxygen" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | # Documenting your code and data with Roxygen 15 | 16 | We all know that documenting our code is important, but equally important is to be able to read that documentation. If you use R, you know that the help feature (?function) is essential. If you organize your code into an R package, it is super easy to create help files that you and users can use to call up using ?. Documenting code may sound like a snoozer of a topic, but using Roxygen and diligently writing documentation for my functions and data is one of the top 3 habits that has made my coding more efficient. You can also document all your data in the same way. 17 | 18 | For more help on Roxygen, see the section in Hadley Wickham's book R Packages on [Documentation](http://r-pkgs.had.co.nz/man.html). Here's a short cheatsheet [Roxygen helper](https://stuff.mit.edu/afs/athena/software/r/current/RStudio/resources/roxygen_help.html). Also Roxygen has good tutorials and help. Type 19 | ``` 20 | browseVignettes(package="roxygen2") 21 | ``` 22 | to open a browser window with links to the tutorials. 23 | 24 | ## Type of documentation 25 | 26 | Roxygen (and the the 'Build and Install' step) will create a the help files that users access with `?function.name. 27 | 28 | The same man files are also used to create a package manual, e.g. 29 | https://cran.r-project.org/web/packages/MARSS/MARSS.pdf 30 | 31 | And it generates the navigation page for all the documentation 32 | ``` 33 | help(package="forecast") 34 | ``` 35 | 36 | The man files are also used by **pkgdown** to make a website version of your documentation. 37 | Here is an example of the default [pkgdown-generated webpage](http://jebyrnes.github.io/multifunc/index.html). 38 | 39 | ### Not just for public products! 40 | 41 | This is an example of a package that is purely *personal*. It is for the data, and a few utility functions, for a group of researchers working with a shared set of data. 42 | 43 | ``` 44 | help(package="SardineForecast") 45 | ``` 46 | 47 | 48 | ## Set-up 49 | 50 | ### Install the **roxygen2** R package. 51 | 52 | ``` 53 | install.packages("roxygen2") 54 | ``` 55 | 56 | Open your test package, **MyNewPackage**. Open RStudio and then click the little arrow next to the blue cube in the top right corner. 57 | 58 | ### Set the Project Build Options to use Roxygen 59 | 60 | Tools > Project Options... > Build Tools > then check the checkbox "Generate documentation with Roxygen". Then click "Configure". Check the box at the bottom for "Install and Restart". 61 | 62 | ## Basic structure of Roxygen2 comments 63 | 64 | Roxygen comments with #' are put at the top of your function, in the same file. They have a standard format and standard sections. There is a bit of customization you can do, but the following basic form will cover 95% of your needs. 65 | 66 | ``` 67 | #' @title Short title 68 | #' 69 | #' @description 70 | #' Description should be one paragraph. Put details in details. 71 | #' 72 | #' @details 73 | #' Optional if you want to add more detais.J 74 | #' 75 | #' @param param.name1 Describe all your function arguments 76 | #' @param param.name2 Describe all your function arguments 77 | #' 78 | #' @examples 79 | #' # provide some examples of how to use your function 80 | #' hello() 81 | #' 82 | #' @seealso List relevant other functions 83 | #' 84 | #` @references 85 | #' List references 86 | #' @export 87 | yourfunction <- function(param.name1, param.name2){} 88 | ``` 89 | 90 | `@title` and `@description` can be left off (not the text, just the @.... part), but title text should be in line 1, then a blank line (#' only), and then the description text. The only required elements are `@title`, `@description`, and `@param` (defining the function arguments). 91 | 92 | `@export` means that your function is added to your NAMESPACE so is not hidden. Just include this for now. 93 | 94 | 95 | ## Add help to `hello()` 96 | 97 | First remove the old `hello.Rd` file from the man folder. That is there because when we created our new package using RStudio's template, we didn't select 'use Roxygen' so it added a manually created help (i.e. Rd) file for us in the man folder. Now we are going to use Roxygen, so we need to remove that file. 98 | 99 | Copy and paste this to the top of `hello.r` in the R folder. Replace all the comments at the top with these lines. 100 | 101 | ``` 102 | #' Hello World! 103 | #' 104 | #' Prints a the classic first program greeting. It takes no arguments. 105 | #' 106 | #' @examples 107 | #' hello() 108 | #' @export 109 | ``` 110 | 111 | To build the documentation, click 'Install and Restart' from the Build tab. 112 | 113 | Once you see that `MyNewPackage` is reloaded (`library(MyNewPackage)` appears on the command line), you can type `?hello` to get the help info. 114 | 115 | ### The NAMESPACE 116 | 117 | Roxygen will complain that the NAMESPACE was not generated by Roxygen so it is ignoring our `@export`. Let delect the NAMESPACE file and try again. 118 | 119 | ## Updating the documentation 120 | 121 | When you update the documentation or add new documentation, rebuild the help files using the 'Install and Restart' button on the Build tab. Note, with the default Project Options, RStudio does not remake the documentation when you click 'Install and Restart'. You have to change that by going to Tools > Project Options > Build Tools and then clicking 'Configure' next to 'Generate documentation with Roxygen' and then clicking the box next to 'Install and Restart'. Or you can run this code to make the documentation. 122 | 123 | ``` 124 | devtools::document() 125 | ``` 126 | 127 | 128 | ## Customizing your help files 129 | 130 | The easiest way to figure out how to customize Roxygen headers is to look at the Roxygen header for a help file you are trying to copy. 131 | 132 | ### Adding references 133 | 134 | If you use BibTex you can insert references by citation in your help files. 135 | 136 | 1. Create the `inst` folder if you don't have one 137 | 2. Within that, create `REFERENCES.bib` 138 | 3 Add refs to that in BibTex format. 139 | 4. Install the **Rdpack** package 140 | 5. Add **Rdpack** to `Imports` in your DESCRIPTION file and add `RdMacros: Rdpack` to your DESCRIPTION file. 141 | 3. Cite in your Roxygen header using 142 | ``` 143 | \insertRef{Waltonetal1998}{MyNewPackage} 144 | ``` 145 | 146 | 147 | Example of a reference in `REFERENCES.bib` 148 | 149 | ``` 150 | @article{Waltonetal1998, 151 | title={The development and operational application of nonlinear algorithms for the measurement of sea surface temperatures with the NOAA polar-orbiting environmental satellites}, 152 | author={Walton, CC and Pichel, WG and Sapper, JF and May, DA}, 153 | journal={Journal of Geophysical Research: Oceans}, 154 | volume={103}, 155 | number={C12}, 156 | pages={27999--28012}, 157 | year={1998}, 158 | publisher={Wiley Online Library} 159 | } 160 | ``` 161 | 162 | You can get the citation for R packages from 163 | 164 | ``` 165 | citation(package="ggplot2") 166 | ``` 167 | 168 | Add the citation to your Rd file with 169 | 170 | ``` 171 | \insertRef{Waltonetal1998}{MyNewPackage} 172 | ``` 173 | 174 | 175 | 176 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Creative Commons Legal Code 2 | 3 | CC0 1.0 Universal 4 | 5 | CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE 6 | LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN 7 | ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS 8 | INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES 9 | REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS 10 | PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM 11 | THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED 12 | HEREUNDER. 13 | 14 | Statement of Purpose 15 | 16 | The laws of most jurisdictions throughout the world automatically confer 17 | exclusive Copyright and Related Rights (defined below) upon the creator 18 | and subsequent owner(s) (each and all, an "owner") of an original work of 19 | authorship and/or a database (each, a "Work"). 20 | 21 | Certain owners wish to permanently relinquish those rights to a Work for 22 | the purpose of contributing to a commons of creative, cultural and 23 | scientific works ("Commons") that the public can reliably and without fear 24 | of later claims of infringement build upon, modify, incorporate in other 25 | works, reuse and redistribute as freely as possible in any form whatsoever 26 | and for any purposes, including without limitation commercial purposes. 27 | These owners may contribute to the Commons to promote the ideal of a free 28 | culture and the further production of creative, cultural and scientific 29 | works, or to gain reputation or greater distribution for their Work in 30 | part through the use and efforts of others. 31 | 32 | For these and/or other purposes and motivations, and without any 33 | expectation of additional consideration or compensation, the person 34 | associating CC0 with a Work (the "Affirmer"), to the extent that he or she 35 | is an owner of Copyright and Related Rights in the Work, voluntarily 36 | elects to apply CC0 to the Work and publicly distribute the Work under its 37 | terms, with knowledge of his or her Copyright and Related Rights in the 38 | Work and the meaning and intended legal effect of CC0 on those rights. 39 | 40 | 1. Copyright and Related Rights. A Work made available under CC0 may be 41 | protected by copyright and related or neighboring rights ("Copyright and 42 | Related Rights"). Copyright and Related Rights include, but are not 43 | limited to, the following: 44 | 45 | i. the right to reproduce, adapt, distribute, perform, display, 46 | communicate, and translate a Work; 47 | ii. moral rights retained by the original author(s) and/or performer(s); 48 | iii. publicity and privacy rights pertaining to a person's image or 49 | likeness depicted in a Work; 50 | iv. rights protecting against unfair competition in regards to a Work, 51 | subject to the limitations in paragraph 4(a), below; 52 | v. rights protecting the extraction, dissemination, use and reuse of data 53 | in a Work; 54 | vi. database rights (such as those arising under Directive 96/9/EC of the 55 | European Parliament and of the Council of 11 March 1996 on the legal 56 | protection of databases, and under any national implementation 57 | thereof, including any amended or successor version of such 58 | directive); and 59 | vii. other similar, equivalent or corresponding rights throughout the 60 | world based on applicable law or treaty, and any national 61 | implementations thereof. 62 | 63 | 2. Waiver. To the greatest extent permitted by, but not in contravention 64 | of, applicable law, Affirmer hereby overtly, fully, permanently, 65 | irrevocably and unconditionally waives, abandons, and surrenders all of 66 | Affirmer's Copyright and Related Rights and associated claims and causes 67 | of action, whether now known or unknown (including existing as well as 68 | future claims and causes of action), in the Work (i) in all territories 69 | worldwide, (ii) for the maximum duration provided by applicable law or 70 | treaty (including future time extensions), (iii) in any current or future 71 | medium and for any number of copies, and (iv) for any purpose whatsoever, 72 | including without limitation commercial, advertising or promotional 73 | purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each 74 | member of the public at large and to the detriment of Affirmer's heirs and 75 | successors, fully intending that such Waiver shall not be subject to 76 | revocation, rescission, cancellation, termination, or any other legal or 77 | equitable action to disrupt the quiet enjoyment of the Work by the public 78 | as contemplated by Affirmer's express Statement of Purpose. 79 | 80 | 3. Public License Fallback. Should any part of the Waiver for any reason 81 | be judged legally invalid or ineffective under applicable law, then the 82 | Waiver shall be preserved to the maximum extent permitted taking into 83 | account Affirmer's express Statement of Purpose. In addition, to the 84 | extent the Waiver is so judged Affirmer hereby grants to each affected 85 | person a royalty-free, non transferable, non sublicensable, non exclusive, 86 | irrevocable and unconditional license to exercise Affirmer's Copyright and 87 | Related Rights in the Work (i) in all territories worldwide, (ii) for the 88 | maximum duration provided by applicable law or treaty (including future 89 | time extensions), (iii) in any current or future medium and for any number 90 | of copies, and (iv) for any purpose whatsoever, including without 91 | limitation commercial, advertising or promotional purposes (the 92 | "License"). The License shall be deemed effective as of the date CC0 was 93 | applied by Affirmer to the Work. Should any part of the License for any 94 | reason be judged legally invalid or ineffective under applicable law, such 95 | partial invalidity or ineffectiveness shall not invalidate the remainder 96 | of the License, and in such case Affirmer hereby affirms that he or she 97 | will not (i) exercise any of his or her remaining Copyright and Related 98 | Rights in the Work or (ii) assert any associated claims and causes of 99 | action with respect to the Work, in either case contrary to Affirmer's 100 | express Statement of Purpose. 101 | 102 | 4. Limitations and Disclaimers. 103 | 104 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 105 | surrendered, licensed or otherwise affected by this document. 106 | b. Affirmer offers the Work as-is and makes no representations or 107 | warranties of any kind concerning the Work, express, implied, 108 | statutory or otherwise, including without limitation warranties of 109 | title, merchantability, fitness for a particular purpose, non 110 | infringement, or the absence of latent or other defects, accuracy, or 111 | the present or absence of errors, whether or not discoverable, all to 112 | the greatest extent permissible under applicable law. 113 | c. Affirmer disclaims responsibility for clearing rights of other persons 114 | that may apply to the Work or any use thereof, including without 115 | limitation any person's Copyright and Related Rights in the Work. 116 | Further, Affirmer disclaims responsibility for obtaining any necessary 117 | consents, permissions or other rights required for any use of the 118 | Work. 119 | d. Affirmer understands and acknowledges that Creative Commons is not a 120 | party to this document and has no duty or obligation with respect to 121 | this CC0 or use of the Work. 122 | -------------------------------------------------------------------------------- /Git-RStudio.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Notes on Git and RStudio" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | # Using Git in RStudio 15 | 16 | You can read a whole book about Git and R [Happy Git with R](http://happygitwithr.com/index.html). 17 | 18 | Using Git in RStudio can be hard to set-up and hard to debug if you run into problems. If you want to use it, [read these instructions](https://cfss.uchicago.edu/git07.html). 19 | 20 | In particular, read the part about how to set-up so you don't have to enter your username and password for every commmit. 21 | 22 | ## Creating a local repository and then getting it on GitHub (or GitLab) 23 | 24 | Note. Creating the repo locally first often leads to misery in my experience. Often safer to start by making a blank repo on GitHub or GitLab. 25 | 26 | ### Let's create a local repository 27 | 28 | 1. Create a RStudio project (upper right with the blue cube with R). New project... > New Directory > New Project 29 | 2. Check the box that says `Create a git repository`. You have made a local repository. 30 | 3. Add a file. File > New File > R Script 31 | 4. Type something and then save the file. 32 | 5. Click the `Git` tab in the upper right. 33 | 6. Click the changes that you want to commit (do all). And click `Commit`. Add a comment: first line is subject, newline, description (options). 34 | 7. Repeat 4-6 a few times. 35 | 8. Now look at the history. The little clock-like icon (or History in the Git window). 36 | 37 | * Click on `filter by file` to see just the changes to one file. 38 | * Do a search in the upper right. 39 | * Click on an early commit and click `View file @...` 40 | 41 | ## Now let's get this on GitHub (similar strategy if you are working on GitLab) 42 | 43 | 1. Go to GitHub and create a repo with the same name 44 | 2. Don't select add Readme or anything 45 | 3. A page that tells you how to get started should show up. Look for this code. 46 | 47 | **…or push an existing repository from the command line** 48 | ``` 49 | git remote add origin https://github.com//.git 50 | git push -u origin master 51 | ``` 52 | 53 | 4. Copy the code and go back to RStudio. 54 | 5. Click the cog on the Git tab and click Shell 55 | 6. Paste the code into the command line. 56 | 7. If you see something about Keychain, try Deny. It will hopefully ask you for your GitHub account info on the command line. 57 | 8. If it all works, you should now be able to push. 58 | 59 | 60 | ## Methods for downloading repositories 61 | 62 | If you want to copy someone's repository on GitHub or make a copy of one of your own, there are a few approaches that you can take. I am going to use `https://github.com/RVerse-Tutorials/Test` as the repository that you want to copy and we will put the repository at `Documents/GitHub/Test`. 63 | 64 | ### Method #1 Fork it 65 | 66 | 1. Navigate to `https://github.com/RVerse-Tutorials/Test` on GitHub and click the 'fork' button in the upper right. Follow the instructions. 67 | 68 | Now you need to get it on your computer. 69 | 70 | 2. From RStudio, go to the menu option 71 | 'File->New Project...'. Then from the resulting dialog, choose 72 | "Version Control". Then choose "Git". Then it asks for a "repository URL". 73 | Supply this: `https://github.com//Test` and 74 | leave the "Project Directory Name" empty. And then choose a directory 75 | in which to put the new repository and click OK. 76 | 77 | If you are using GitHub Desktop, you need to add it to that too. 78 | 79 | 3. From GitHub Desktop, go to the menu option 80 | 'File->Add Local Repository'. Then navigate to `~/Documents/GitHub/Test` and add. 81 | 82 | The problem with forking is that you can't fork your own repositories and if you fork someone else's repository, your fork will always show theirs as a 'parent'---which doesn't really have a bad effect but I rarely want my copy of someone's repo to be linked to theirs in any way. Normally forking is used when you are contributing to the parent repository and need a copy to work on. 83 | 84 | ### Method #2 Copying my OWN repos (not someone else's) 85 | 86 | This method is pretty failsafe and I find easy to remember. This how I normally copy one of my own folders and make a new GitHub repo. I don't use Git at the command line very often and rather than looking up how to do it, getting something wrong 3x and then researching how to debug the problem, and then finding I've spent the morning with a simple task.... I just do the following now. 87 | 88 | 1. Make a new repo (say `Test`) on GitHub and click the button to add a Readme.md file. 89 | 2. Download and link to the new repo using Step 2 above (in Method #1). 90 | 3. Add the repo to GitHub Desktop using Step 3 above (in Method #1) 91 | 4. Copy the files (on my computer) from the repo I want to copy into the new folder. Note this works because I already have the files I want on my computer. 92 | 5. Push these changes to GitHub, though the Git tab in RStudio or GitHub Desktop (my preference). 93 | 94 | ### Method #4 95 | 96 | 1. From RStudio, go to the menu option 97 | 'File->New Project...'. Then from the resulting dialog, choose 98 | "Version Control". Then choose "Git". Then it asks for a "repository URL". 99 | Supply this: `https://github.com/RVerse-Tutorials/Test` and 100 | leave the "Project Directory Name" empty. And then choose a directory 101 | in which to put it and click OK. 102 | 103 | This method will have your new repository associated with the repository from where you downloaded. If it is not your own GitHub repository, you don't want this because you will not be able to push changes to GitHub. 104 | 105 | 2. Click on the 'More' link in the Git Window of RStudio, and click 'Shell'. Then issue this command. 106 | ``` 107 | git remote rm origin 108 | ``` 109 | This detaches the cloned repository from the remote repository on GitHub from where you cloned it. 110 | 111 | 3. Add the new repository to GitHub Desktop and then publish to GitHub. From GitHub Desktop, go to File>Add Local Repository and then navigate to `~/Documents/GitHub/Test` and add. 112 | 113 | 4. Publish to GitHub. Once you do step 3, a 'Publish to GitHub' button will appear. Click that to publish to GitHub. 114 | 115 | Note, there are Git commands you could use to do steps 3 and 4, but in this workshop we are using GitHub Desktop. 116 | 117 | ### Alternate Method #5 118 | 119 | Another way is to download the repository as a zip file and unzip. [Watch a video that shows you how to do this](https://youtu.be/bYySjso7vRo) 120 | 121 | Go to https://github.com/RVerse-Tutorials/Test and click 'Clone or download' and chose 'Download Zip'. Unzip and you'll probably want to remove 'master' added to the end of the repository name. 122 | 123 | If you chose, 'Clone in Desktop', you'll need to open a terminal window, navigate to the new folder you just downloaded, and run the git code `git remote rm origin` from within the terminal to detach the repository from the RVerse-Tutorials GitHub account. 124 | 125 | 126 | ## Packages with C++ code 127 | 128 | We will not be doing this in this short course, but often you will want to install packages with C++ code. To do that, you will need Rtools (Windows) or Xcode (Mac) 129 | 130 | * **Rtools** Windows users [Rtools](https://cran.r-project.org/bin/windows/Rtools/) also so you can build packages with C++ code if needed. See comments here about changing path. [Rtools](http://stat545.com/packages01_system-prep.html#windows-system-prep) 131 | 132 | * **Xcode** Mac users Open terminal and type the following command `xcode-select --install` 133 | 134 | -------------------------------------------------------------------------------- /websites.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Simple Websites from Rmds" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | This will show you how to make a very simple website with R Markdown and put that online via GitHub Pages. When you are ready to learn more go to the [Links](links.html) page for more tutorials. 15 | 16 | ## Simple website template 17 | 18 | Clone the [RVerse-Tutorials\Test-Website](https://github.com/RVerse-Tutorials/Test-Website) repository. 19 | 20 | * Copy the URL. 21 | * Open GitHub and click the "+" in top right for new repo. Select 'Import repository', then select import from URL and paste in the URL. 22 | * Once it is imported (might take awhile), copy the URL for **your** new repository. 23 | * Open RStudio. Click the blue cube with R in top right. Select New Project > Version Control > Git and paste in the URL. 24 | 25 | Now you'll have a copy of Test-Website on GitHub and a copy on your computer that is linked to your remote repository (on GitHub). 26 | 27 | 28 | ## Build the website 29 | 30 | 31 | 2. From RStudio, click 'Build' from upper right and then 'Build Website'. Your website should open. You can select 'View in browser'. 32 | 33 | - You can also right click on 'index.html' from the files, and select 'open in browser'. 34 | 35 | [Watch a video of this step](https://youtu.be/94iHk0UnxJc) 36 | 37 | ## Overview 38 | 39 | There are two required files for a website plus your content (your R Markdown files). 40 | 41 | The first required file is `_site.yml` which is your configuration file. 42 | 43 | The second required file is `index.Rmd` which is your landing page or page #1. 44 | 45 | Your content is specified in additional R Markdown files. Not required, but your website is not very interesting without content. 46 | 47 | ## _site.yml 48 | 49 | The `_site.yml` specifies the basic info about your site and the navigation bar at top. 50 | 51 | ``` 52 | name: "my-website" 53 | output_dir: "." 54 | navbar: 55 | title: "My Website" 56 | left: 57 | - text: "Home" 58 | icon: fa-home 59 | href: index.html 60 | - text: "About" 61 | icon: fa-bullhorn 62 | href: about.html 63 | menu: 64 | - text: "Page A" 65 | href: page_a.html 66 | - text: "Page B" 67 | href: page_b.html 68 | output: 69 | html_document: 70 | theme: readable 71 | toc_depth: 3 72 | toc_float: 73 | collapsed: false 74 | ``` 75 | 76 | ## index.Rmd 77 | 78 | `index.Rmd` is just your landing page. You can have as little or as much content as you want here. When readers click on your site, they will see this page first. 79 | 80 | A minimal `index.Rmd` would look like: 81 | 82 | ``` 83 | --- 84 | title: "My website" 85 | --- 86 | 87 | Here is my website. 88 | ``` 89 | 90 | ## Content 91 | 92 | You can now add as many Rmarkdown files as you want for your content. Each one will be processed into an html file. For example in `Test Website`, we have two files, `about.Rmd` and `contact.Rmd`. Your Rmd files should have the yaml at top and then your Rmarkdown content. 93 | 94 | Here is a simple example. 95 | 96 | ``` 97 | --- 98 | title: Simple Rmd File 99 | --- 100 | 101 | Here is a simple file. 102 | ``` 103 | 104 | `about.Rmd` is a fuller Rmd file with R code and figures. 105 | 106 | If you want the file linked to in your top nav bar, then add it to `_site.yml`. 107 | 108 | ``` 109 | name: "my-website" 110 | output_dir: "." 111 | navbar: 112 | title: "My Website" 113 | left: 114 | - text: "About" 115 | href: about.html 116 | - text: "Contact" 117 | icon: fa-user-circle 118 | href: contact.html 119 | output: 120 | html_document: 121 | theme: readable 122 | toc_depth: 3 123 | toc_float: 124 | collapsed: false 125 | ``` 126 | 127 | ## Make your website live 128 | 129 | [Watch a video of this step](https://youtu.be/eHWi5XmTO8U) 130 | 131 | Here is how to make your website live on GitHub. 132 | 133 | First you need to add this as a repository on GitHub. 134 | 135 | 1. Open GitHub Desktop and select File > New Repository. Type 'Test-Website' (or if you renamed it, then whatever you renamed it to). Leave everything else blank (for now). 136 | 137 | 2. This adds your repository to GitHub Desktop. Now click 'Publish' in the top right corner. If 'private' is checked, uncheck that. 138 | 139 | Next you need to open your repository on GitHub and set it up to serve a webpage. 140 | 141 | 1. Go to your GitHub account. 142 | 2. Click on the new Test-Website repository. 143 | 3. Click on Settings. 144 | ![Settings](images/GitHub_pages_1.png) 145 | 4. Scroll down to GitHub Pages and change source from 'none' to 'master branch'. 146 | ![Source](images/GitHub_pages_2.png) 147 | 5. Wait a few minutes and then go to your new webpage. The link will appear just above where your changed the source. 148 | 149 | ## Extras 150 | 151 | ### Table of Contents 152 | 153 | If you want to see table of contents for your Rmd files, you specify toc properties in your `_site.yml` file. 154 | 155 | ``` 156 | output: 157 | html_document: 158 | theme: readable 159 | toc_depth: 3 160 | toc_float: 161 | collapsed: false 162 | ``` 163 | 164 | and specify `toc: true` in your yaml at the top of your Rmd file. 165 | 166 | ``` 167 | output: 168 | html_document: 169 | toc: true 170 | ``` 171 | 172 | See the `about.Rmd` file for an example. 173 | 174 | ### Themes 175 | 176 | Your `_site.yml` file has a line that specifies the theme. 177 | 178 | ``` 179 | output: 180 | html_document: 181 | theme: readable 182 | ``` 183 | 184 | The following are automatically available to you: bootstrap, cerulean, cosmo, flatly, journal, lumen, paper, readable, sandstone, simplex, spacelab, united and yeti. Try changing the theme to one of these and rebuilding your website. 185 | 186 | You can download other bootstrap css files and put in site_libs if you want other themes. Do a search for 'bootstrap themes free'. 187 | 188 | ### Icons 189 | 190 | You can easily add icons to your navigation tabs. The `icon:` line specifies the icon. See the FontAwesome website for icons available. Put `fa-` in front of the name. For example a photo icon would be specified `fa-picture-o`. 191 | 192 | ``` 193 | left: 194 | - text: "Set-up" 195 | icon: fa-picture-o 196 | href: setup.html 197 | ``` 198 | 199 | ### Customizing 200 | 201 | You can add your own css file to customize the html. Add to your `_site.yml` file: 202 | 203 | ``` 204 | output: 205 | html_document: 206 | theme: cosmo 207 | highlight: textmate 208 | include: 209 | after_body: footer.html 210 | css: styles.css 211 | ``` 212 | 213 | And then add a `styles.css` file to your folder. You can change all the h1 headers to green. 214 | 215 | ``` 216 | h1 { 217 | font-color: green 218 | } 219 | ``` 220 | 221 | Change the font-family and add some more space. 222 | 223 | ``` 224 | body { 225 | font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; 226 | line-height: 2; 227 | } 228 | ``` 229 | 230 | Add more spacing between the sections. 231 | 232 | ``` 233 | .section { 234 | padding-bottom: 2em; 235 | } 236 | ``` 237 | 238 | Etc, etc, etc, etc. 239 | 240 | ### Fixing a navbar that wraps 241 | 242 | The bootstrap css doesn't handle navbars with many tabs very well. It wraps and covers up the text. Adding the following to your `styles.css` file will fix that. 243 | 244 | ``` 245 | /* Need to adjust the navbar behaviour so the navbar doesn't wrap */ 246 | .navbar-nav { 247 | position: fixed; 248 | left: 150px; 249 | width: 700px; 250 | } 251 | 252 | .navbar-header { 253 | position: fixed; 254 | left: 30px; 255 | width: 97%; 256 | } 257 | ``` 258 | -------------------------------------------------------------------------------- /README.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | README.utf8.md 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 42 | 43 | 44 | 45 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 102 | 103 | 104 | 137 | 138 | 155 | 156 | 157 |
    158 | 159 | 160 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 283 | 284 | 290 | 291 | 292 |
    293 |

    Website for the RWorkflow INCOIS Short Course

    294 |
      295 |
    • Simple website built with R Markdown ‘Build Website’ function.
    • 296 |
    • Click the ‘Build Website’ button in RStudio to make.
    • 297 |
    298 |
    299 | 300 | 301 | 302 | 303 |
    304 | 305 | 317 | 318 | 319 | 327 | 328 | 329 | 330 | -------------------------------------------------------------------------------- /intro-git.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Introduction to Git within RStudio" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 15 | library(kableExtra) 16 | dt <- data.frame("Compartmentalized", "Documented", "Extendible", "Reproducible", "Robust") 17 | kable(dt, col.names=NULL) %>% 18 | kable_styling(full_width = TRUE) %>% 19 | row_spec(1, bold = FALSE, color = "white", background = "blue") %>% 20 | column_spec(column = 1:5, width = "20%") 21 | ``` 22 | 23 | # Overview 24 | 25 | I will introduce you to RStudio and GitHub/GitLab and show you how to use GitHub/GitLab without having to learn Git. If you have tried RStudio or Git and gotten frustrated or thought 'I don't have time to learn this', this is for you. If you want to learn how to easily keep track of changes in your code, this is for you. If you have never used RStudio, this is for you. 26 | 27 | I'm going to show you how to work with Git/GitHub/GitLab with no command-line interface. The goal is to futz with Git as little as possible. See the Links tab above for a nice online workshop on Git/GitHub if you want to learn more. 28 | 29 | # RStudio 30 | 31 | When you open RStudio you will see 4 panels: 32 | 33 | ![RStudio-panels](images/RStudio-screenshot.png) 34 | 35 | ## Create an RStudio Project 36 | 37 | 1. In RStudio, choose "File->New Project..." 38 | 1. Then choose "New Directory" and then choose "Empty Project" 39 | 1. In the next dialog, choose a name (_it is best to use only letters, numbers, dashes, and underscores, and include no spaces in the name_). 40 | 1. Then click "Create Project". 41 | 42 | That should give you a new project. 43 | 44 | ### Add a new script file 45 | 46 | 1. Add a new file using 'File > New File > R Script' 47 | 2. Or you can click the new icon in top left corner. 48 | 2. Add some code to that file. Copy and paste in: 49 | 50 | ``` 51 | require(graphics) 52 | ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". 53 | ## Page 9: Plant Weight Data. 54 | ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) 55 | trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) 56 | group <- gl(2, 10, 20, labels = c("Ctl","Trt")) 57 | weight <- c(ctl, trt) 58 | lm.D9 <- lm(weight ~ group) 59 | opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) 60 | plot(lm.D9, las = 1) # Residuals, Fitted, ... 61 | par(opar) 62 | ``` 63 | 64 | ### Run the code 65 | 66 | 1. Select all the lines of code and select 'Run' 67 | 2. Run all the code by selecting 'Source' 68 | 69 | ## Project organization 70 | 71 | Keep your projects in separate folders with a uniform set of folder names. For example, 72 | 73 | * R - your functions 74 | * scripts - scripts (so not functions) 75 | * data - your RData files 76 | * output - 77 | * inst - random stuff 78 | * notes - 79 | 80 | The top right corner allows you to create projects and switch between projects. 81 | 82 | ![RStudio-panels](images/RStudio-screenshot.png) 83 | 84 | ### Project settings 85 | 86 | Key one is to **not** save your `.Rdata` (your environment) when your are done for the day. Under Tools > Project Options... > General 87 | 88 | ## Super helpful features 89 | 90 | * Edit > Find in Files... 91 | * Code > Comment 92 | * Code > Reindent Lines 93 | * File > New (templates) 94 | * History tab 95 | * Help tab (index at bottom) 96 | * Help > Markdown quick reference 97 | 98 | ## More exercises 99 | 100 | R for Data Science is a great book to introduce you to working with data in R. Read through the following sections of the R for Data Science book and work through the examples. 101 | 102 | * [Workflow basics](http://r4ds.had.co.nz/workflow-basics.html): super basic review on how R works. 103 | * [Workflow: projects](http://r4ds.had.co.nz/workflow-projects.html): info about organizing RStudio projects. 104 | * [Workflow: scripts](http://r4ds.had.co.nz/workflow-scripts.html): how to evaluate code in scripts. 105 | 106 | # Git (GitHub/GitLab) 107 | 108 | Tracking your code (and project) changes. I am focusing on Git for individuals **not teams**. If you aren't using a change tracker (version control), then start just with a personal project and track only your changes. I will not cover *branches*. 109 | 110 | For NOAA staff, GitHub can be used for publishing public projects: 111 | [NOAA GitHub](https://github.com/NOAAGov/NOAA-Affiliated-Projects) and a NWFSC example 112 | [NWFSC Timeseries](https://nwfsc-timeseries.github.io/). NWFSC has a GitLab server if you want a repository server for your non-public projects and for internal collaboration. 113 | 114 | ## Basics 115 | 116 | * Repo: Repository. It is your code and the record of your changes. In a hidden folder called `.git` (so if you wanted to get rid of the history and other Git info, you could delete that folder). You have a local repo and a remote repo (on GitHub/GitLab). 117 | * Actions: Commit, Push, Pull 118 | * Git: The program that keeps track of the changes on local and remote repo. 119 | * Git GUIs: A graphical interface for Git (which is command line). There are [many](https://git-scm.com/downloads/guis). I am teaching an easy-entry one, GitHub Desktop. 120 | 121 | Workflow (to get started): 122 | 123 | * Make local changes to code. 124 | * Record what those changes were about and commit to the code change record (history). 125 | * Push those changes to your remote copy (aka your backup) 126 | 127 | ![First foray into Git/GitHub/GitLab](images/git-intro.png) 128 | 129 | Goals today: 130 | 131 | 1. Get you started. 132 | 2. Show you a simple workflow. 133 | 3. Show some simple GitHub/GitLab features. 134 | 135 | ## Let's get started! 136 | 137 | I am going to show a workflow that is usually robust. Connecting Git on your computer and GitHub (or GitLab) is a source of much misery, and in my experience **creating the repo on GitHub (or GitLab) first** eliminates the problems. This really important for the first time you connect your computer to the remote repository server (GitHub or GitLab). Start with a new repo created on GitHub or GitLab. 138 | 139 | ### Make a GitHub or GitLab Repo 140 | 141 | 1. Go to GitHub or GitLab and create a new repository (the + in the top right or New Project) 142 | 2. Click add Readme.md and add .gitignore (type R to get the R .gitignore) 143 | 3. Copy the url of your new repo 144 | 145 | ### Add to RStudio 146 | 147 | 1. Open RStudio and click `New Project` (upper right, blue cube with R) 148 | 2. Click New Project... > Version Control > Git and paste in the url. Give your project a name and make sure the directory is where you want the project. 149 | 3. Done! 150 | 151 | ### Make some changes and commit 152 | 153 | 1. Add a file. File > New File > R Script 154 | 2. Type something and then save the file. 155 | 3. Click the `Git` tab in the upper right. 156 | 4. Click the changes that you want to commit (do all). And click `Commit`. Add a comment: first line is subject, newline, description (options). 157 | 5. Click the Green up arrow to Push to GitHub or GitLab. 158 | 159 | ### Make some changes and look at the history 160 | 161 | 1. Repeat 1-4 a few times. 162 | 2. Now look at the history. The little clock-like icon (or History in the Git window). 163 | 164 | * Click on `filter by file` to see just the changes to one file. 165 | * Do a search in the upper right. 166 | * Click on an early commit and click `View file @...` 167 | 168 | 3. Push changes up the GitHub or GitLab 169 | 170 | ## Copy someone's else rep 171 | 172 | 1. In a browser, https://github.com/RVerse-Tutorials/Test. 173 | 2. Copy its url. 174 | 3. Open GitHub or GitLab. 175 | 4. If using GitHub, click the `+` in top right and click `import repository`. Paste in the url and give your repo a name. 176 | 4. If using GitLab, click `New Project` on right, then `Import Repository` tab, then click `Repo by URL`. Paste in url and give repo a name. 177 | 5. Open RStudio and click the project tab in the top right and select, `New Project`. Then select `Version Control` and paste in the url of **your** repository's url. For example, `https://github.com//Test` or 178 | `https://gitlab.com//Test` or 179 | 180 | 6. Add the new repo to GitHub Desktop. Open GitHub Desktop, select File>Add Local Repository and navigate to the folder with the new repository. 181 | 182 | ## Key tips 183 | 184 | 1. Do not make changes on GitHub or GitLab directly. 185 | 186 | * Waa, I did and then I forget to pull and now I have merge conflicts. What do I do?? I warned you. Now, Google is your friend. 187 | 188 | 2. Do not use branches (wait till you are friends with Git). 189 | 190 | 3. Do not use Git at the command line. 191 | 192 | 4. If you use Dropbox or iCloud on multiple computers to keep folders synced up across different computers, don't put your Git repos in those folders. 193 | 194 | 5. The Git info is in the hidden folder `.git`. If you need to get rid of the repository data (like history), delete that. Don't copy that folder into another repo. 195 | 196 | 6. Start by making a blank repo on GitHub or GitLab and select the box to add a Readme file. Then clone that with RStudio or GitHub Desktop. 197 | 198 | # GitHub Desktop 199 | 200 | Despite the name, it works with GitLab too. 201 | 202 | You can commit your changes and push them with RStudio only, but many people use a Git GUI to interact with Git and their remote repository. GitHub Desktop is simple and works well. Why not just use RStudio? If you are happy with that, fine. Many people prefer a separate Git GUI, though Git with RStudio has improved and serves many just fine. 203 | 204 | ![GitHub Desktop](images/GitHub-Desktop.png) 205 | 206 | ## Adding your local repository 207 | 208 | To use your local repository with GitHub Desktop, you need to add it. 209 | 210 | 1. File > Add Local Repository. 211 | 212 | How does it know what the remote repository (GitHub/GitLab) is? It is stored in the .git information which was set when you cloned the repo from GitHub/GitLab. 213 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /week1-rstudio.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Week 1. Introduction to workflow using RStudio and Git" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 15 | library(kableExtra) 16 | dt <- data.frame("Compartmentalized", "Documented", "Extendible", "Reproducible", "Robust") 17 | kable(dt, col.names=NULL) %>% 18 | kable_styling(full_width = TRUE) %>% 19 | row_spec(1, bold = FALSE, color = "white", background = "blue") %>% 20 | column_spec(column = 1:5, width = "20%") 21 | ``` 22 | 23 | # Overview 24 | 25 | I will introduce you to RStudio and GitHub/GitLab I will show you a variety of approaches for organizing your projects that involve code and show you how to use GitHub/GitLab without having to learn Git. If you already use RStudio and Git, skip this week as this will be introductory level. If you have tried RStudio or Git and gotten frustrated or thought 'I don't have time to learn this', this is for you. If you want to learn how to easily keep track of changes in your code, this is for you. If you have never used RStudio, this is for you. 26 | 27 | I'm going to show you how to work with Git/GitHub/GitLab with no command-line interface. The goal is to futz with Git as little as possible. See the Links tab above for a nice online workshop on Git/GitHub if you want to learn more. 28 | 29 | # RStudio 30 | 31 | When you open RStudio you will see 4 panels: 32 | 33 | ![RStudio-panels](images/RStudio-screenshot.png) 34 | 35 | ## Create an RStudio Project 36 | 37 | 1. In RStudio, choose "File->New Project..." 38 | 1. Then choose "New Directory" and then choose "Empty Project" 39 | 1. In the next dialog, choose a name (_it is best to use only letters, numbers, dashes, and underscores, and include no spaces in the name_). 40 | 1. Then click "Create Project". 41 | 42 | That should give you a new project. 43 | 44 | ### Add a new script file 45 | 46 | 1. Add a new file using 'File > New File > R Script' 47 | 2. Or you can click the new icon in top left corner. 48 | 2. Add some code to that file. Copy and paste in: 49 | 50 | ``` 51 | require(graphics) 52 | ## Annette Dobson (1990) "An Introduction to Generalized Linear Models". 53 | ## Page 9: Plant Weight Data. 54 | ctl <- c(4.17,5.58,5.18,6.11,4.50,4.61,5.17,4.53,5.33,5.14) 55 | trt <- c(4.81,4.17,4.41,3.59,5.87,3.83,6.03,4.89,4.32,4.69) 56 | group <- gl(2, 10, 20, labels = c("Ctl","Trt")) 57 | weight <- c(ctl, trt) 58 | lm.D9 <- lm(weight ~ group) 59 | opar <- par(mfrow = c(2,2), oma = c(0, 0, 1.1, 0)) 60 | plot(lm.D9, las = 1) # Residuals, Fitted, ... 61 | par(opar) 62 | ``` 63 | 64 | ### Run the code 65 | 66 | 1. Select all the lines of code and select 'Run' 67 | 2. Run all the code by selecting 'Source' 68 | 69 | ## Project organization 70 | 71 | Keep your projects in separate folders with a uniform set of folder names. For example, 72 | 73 | * R - your functions 74 | * scripts - scripts (so not functions) 75 | * data - your RData files 76 | * output - 77 | * inst - random stuff 78 | * notes - 79 | 80 | The top right corner allows you to create projects and switch between projects. 81 | 82 | ![RStudio-panels](images/RStudio-screenshot.png) 83 | 84 | ### Project settings 85 | 86 | Key one is to **not** save your `.Rdata` (your environment) when your are done for the day. Under Tools > Project Options... > General 87 | 88 | ## Super helpful features 89 | 90 | * Edit > Find in Files... 91 | * Code > Comment 92 | * Code > Reindent Lines 93 | * File > New (templates) 94 | * History tab 95 | * Help tab (index at bottom) 96 | * Help > Markdown quick reference 97 | 98 | ## More exercises 99 | 100 | R for Data Science is a great book to introduce you to working with data in R. Read through the following sections of the R for Data Science book and work through the examples. 101 | 102 | * [Workflow basics](http://r4ds.had.co.nz/workflow-basics.html): super basic review on how R works. 103 | * [Workflow: projects](http://r4ds.had.co.nz/workflow-projects.html): info about organizing RStudio projects. 104 | * [Workflow: scripts](http://r4ds.had.co.nz/workflow-scripts.html): how to evaluate code in scripts. 105 | 106 | # Git (GitHub/GitLab) 107 | 108 | Tracking your code (and project) changes. I am focusing on Git for individuals **not teams**. If you aren't using a change tracker (version control), then start just with a personal project and track only your changes. I will not cover *branches*. 109 | 110 | For NOAA staff, GitHub can be used for publishing public projects: 111 | [NOAA GitHub](https://github.com/NOAAGov/NOAA-Affiliated-Projects) and a NWFSC example 112 | [NWFSC Timeseries](https://nwfsc-timeseries.github.io/). NWFSC has a GitLab server if you want a repository server for your non-public projects and for internal collaboration. 113 | 114 | ## Basics 115 | 116 | * Repo: Repository. It is your code and the record of your changes. In a hidden folder called `.git` (so if you wanted to get rid of the history and other Git info, you could delete that folder). You have a local repo and a remote repo (on GitHub/GitLab). 117 | * Actions: Commit, Push, Pull 118 | * Git: The program that keeps track of the changes on local and remote repo. 119 | * Git GUIs: A graphical interface for Git (which is command line). There are [many](https://git-scm.com/downloads/guis). I am teaching an easy-entry one, GitHub Desktop. 120 | 121 | Workflow (to get started): 122 | 123 | * Make local changes to code. 124 | * Record what those changes were about and commit to the code change record (history). 125 | * Push those changes to your remote copy (aka your backup) 126 | 127 | ![First foray into Git/GitHub/GitLab](images/git-intro.png) 128 | 129 | Goals today: 130 | 131 | 1. Get you started. 132 | 2. Show you a simple workflow. 133 | 3. Show some simple GitHub/GitLab features. 134 | 135 | ## Let's get started! 136 | 137 | I am going to show a workflow that is usually robust. Connecting Git on your computer and GitHub (or GitLab) is a source of much misery, and in my experience **creating the repo on GitHub (or GitLab) first** eliminates the problems. This really important for the first time you connect your computer to the remote repository server (GitHub or GitLab). Start with a new repo created on GitHub or GitLab. 138 | 139 | ### Make a GitHub or GitLab Repo 140 | 141 | 1. Go to GitHub or GitLab and create a new repository (the + in the top right or New Project) 142 | 2. Click add Readme.md and add .gitignore (type R to get the R .gitignore) 143 | 3. Copy the url of your new repo 144 | 145 | ### Add to RStudio 146 | 147 | 1. Open RStudio and click `New Project` (upper right, blue cube with R) 148 | 2. Click New Project... > Version Control > Git and paste in the url. Give your project a name and make sure the directory is where you want the project. 149 | 3. Done! 150 | 151 | ### Make some changes and commit 152 | 153 | 1. Add a file. File > New File > R Script 154 | 2. Type something and then save the file. 155 | 3. Click the `Git` tab in the upper right. 156 | 4. Click the changes that you want to commit (do all). And click `Commit`. Add a comment: first line is subject, newline, description (options). 157 | 5. Click the Green up arrow to Push to GitHub or GitLab. 158 | 159 | ### Make some changes and look at the history 160 | 161 | 1. Repeat 1-4 a few times. 162 | 2. Now look at the history. The little clock-like icon (or History in the Git window). 163 | 164 | * Click on `filter by file` to see just the changes to one file. 165 | * Do a search in the upper right. 166 | * Click on an early commit and click `View file @...` 167 | 168 | 3. Push changes up the GitHub or GitLab 169 | 170 | ## Copy someone's else repo 171 | 172 | Don't Fork. That would be if you are contributing to their repo. If you just want to copy it and then adapt it for your purposes, do this. 173 | 174 | 1. In a browser, navigate to the repository that you want to copy. For example: https://github.com/RVerse-Tutorials/Test. 175 | 2. Copy its url. 176 | 3. Open GitHub or GitLab and go to your account. So for me, I would go to github.com/eeholmes because my account is eeholmes. 177 | 4. If using GitHub, click the `+` in top right and click `import repository`. Paste in the url and give your repo a name. 178 | 4. If using GitLab, click `New Project` on right, then `Import Repository` tab, then click `Repo by URL`. Paste in url and give repo a name. 179 | 5. Open RStudio and click the project tab in the top right and select, `New Project`. Then select `Version Control` and paste in the url of **your** repository's url. For example, `https://github.com//Test` or 180 | `https://gitlab.com//Test` or 181 | 6. Add the new repo to GitHub Desktop. Open GitHub Desktop, select File>Add Local Repository and navigate to the folder with the new repository. 182 | 183 | ## Key tips 184 | 185 | 1. Do not make changes on GitHub or GitLab directly. 186 | 187 | * Waa, I did and then I forget to pull and now I have merge conflicts. What do I do?? I warned you. Now, go to the Week 7 material to learn how to deal with merge conflicts. 188 | 189 | 2. Do not use branches (wait till you are friends with Git). 190 | 191 | 3. Do not use Git at the command line. 192 | 193 | 4. If you use Dropbox or iCloud on multiple computers to keep folders synced up across different computers, don't put your Git repos in those folders. 194 | 195 | 5. The Git info is in the hidden folder `.git`. If you need to get rid of the repository data (like history), delete that. Don't copy that folder into another repo. 196 | 197 | 6. Start by making a blank repo on GitHub or GitLab and select the box to add a Readme file. Then clone that with RStudio or GitHub Desktop. 198 | 199 | # GitHub Desktop 200 | 201 | Despite the name, it works with GitLab too. 202 | 203 | You can commit your changes and push them with RStudio only, but many people use a Git GUI to interact with Git and their remote repository. GitHub Desktop is simple and works well. Why not just use RStudio? If you are happy with that, fine. Many people prefer a separate Git GUI, though Git with RStudio has improved and serves many just fine. 204 | 205 | ![GitHub Desktop](images/GitHub-Desktop.png) 206 | 207 | ## Adding your local repository 208 | 209 | To use your local repository with GitHub Desktop, you need to add it. 210 | 211 | 1. File > Add Local Repository. 212 | 213 | How does it know what the remote repository (GitHub/GitLab) is? It is stored in the .git information which was set when you cloned the repo from GitHub/GitLab. 214 | 215 | 216 | 217 | -------------------------------------------------------------------------------- /week3-RMarkdown.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "R Markdown for Reports" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | This week will shift gears and talk about writing reports using R Markdown. There are many on-line tutorials for R Markdown which will cover the basics. I'll focus on some of the aspects of R Markdown that can really speed up your work: automating the making of tables and graphs. Our work often involves making tables that process some data and then report that in tables. When the data change (which happens often), we have to remake tables (and graphs). This is very time-consuming and creates errors. I'll show you how to automate this process so you are not manually remaking tables for reports. 15 | 16 | ## Set-up 17 | 18 | If you want to try out the things I am showing, you will need R and RStudio. If you have never made an R Markdown file, there are some packages that you'll need. 19 | 20 | Build your first R Markdown file 21 | 22 | * Open RStudio, and click File > New File > R Markdown... . 23 | * Select the default (document) and click ok. This will open a template R Markdown document. 24 | * Save the file and then click 'Knit' in the nav bar above your template. 25 | * Download the necessary packages if RStudio complains and won't build. 26 | 27 | Note, to make PDF files you will need a LaTeX installation. If you don't have one already (if you are not sure, then you don't), you can install [tinytex](https://yihui.name/tinytex/). Run these lines: 28 | 29 | ``` 30 | install.packages('tinytex') 31 | tinytex::install_tinytex() 32 | ``` 33 | 34 | Note the first time you make a PDF, tinytex will load any needed packages and it can take a **long** time. You'll see a spinning wheel on the R Markdown tab. 35 | 36 | 37 | 38 | ## Overview 39 | 40 | R Markdown is a format that allows you to combine text and R code. From RStudio you can output your file in many formats: html, PDF, Word, presentations. We are exploring a small slice of R Markdown. 41 | 42 | When you are ready to explore more, go to this great R Markdown resource [R Markdown for Scientists](https://rmd4sci.njtierney.com/). [The R Markdown Definitive Guide](https://bookdown.org/yihui/rmarkdown/) is also a good resource. 43 | 44 | 45 | ## Templates 46 | 47 | I have made a repository [Rmarkdown-Tutorial](https://github.com/RVerse-Tutorials/Rmarkdown-Tutorial) with some template Rmd files for you to look at. For this week, you just need the material; you don't to make a repository yourself (linked to GitLab or GitHub). 48 | 49 | To get the material: 50 | 51 | * You can download a zip of the repository. The download button is on the repository link (above) and is a green button that says 'Clone or download'. Unzip that file and then do New Project > Existing Directory and navigate to the directory from the zip file. 52 | * If you have Git installed, click the blue cube with R in the top right corner. New Project > Version Control > Git and then paste in the URL. Note you won't be able to push changes since you cloned from my repository. 53 | * You can also clone to a GitLab or GitHub repo (New Project or Repo > Import from URL) and then pull your clone on GitLab or GitHub into RStudio via New Project > Version Control. 54 | 55 | 56 | ## Basic Rmd file 57 | 58 | Open up `Basic.Rmd`. 59 | 60 | At the top you see 61 | 62 | ``` 63 | --- 64 | title: "Basic" 65 | author: "EE Holmes" 66 | date: "9/2/2018" 67 | output: html_document 68 | --- 69 | ``` 70 | 71 | This is the `yaml` which gives the instructions about how to process your R Markdown file. The `yaml` file is sensitive to spaces. Do not add or subtract spaces. This `yaml` is very simple, but the `yaml` can be complex for some applications. We will only be working with simple examples. 72 | 73 | After the `yaml` is the content. To see a summary of R Markdown formating, click 'Help' menu and then 'Markdown Quick Reference'. 74 | 75 | ## Create output 76 | 77 | We can create documents in different formats from this Rmd file. Click the drop-down menu next to the 'knit' button. 78 | 79 | * **HTML** Select 'knit to HTML' to create a web document. 80 | * **Word** Select 'knit to Word' to create a Word document. 81 | * **PDF** Select 'knit to PDF' to create a PDF. Note need for a LaTeX installation (easiest is tinytex). 82 | 83 | ## Getting help 84 | 85 | In RStudio, click the 'Help' tab in the top nav bar. You will see 'Markdown Quick Reference'. That has basic markdown syntax. You can also click 'Cheatsheets' and there are two references sheets. Using Google, you can also find answers to any questions that the RStudio help files doesn't answer. See also [R Markdown for Scientists](https://rmd4sci.njtierney.com/). 86 | 87 | Tips: 88 | 89 | * Markdown is sensitive to leading spaces. " ## Topic" will not produce a header while "## Topic" will. " ```{r}" (note leading space) will not be interpreted as R code. 90 | * Markdown is sensitive to line returns. If you are tying to make a list, "1. item", then you must have two line returns before the "1. item". 91 | 92 | ## Start a new Rmarkdown file using RStudio template 93 | 94 | Click the File tab, then select New File > R Markdown. This will open a template R Markdown file. You will be asked for a title and whether to have the output be html, PDF, or Word. 95 | 96 | 105 | 106 | 107 | ## Other example Rmds 108 | 109 | * Figures `Figures.Rmd` 110 | * Tables `Table.Rmd` 111 | * Tables for Word, html, or latex `Table_Extras.Rmd` 112 | * Math `Math.Rmd` 113 | * Table of contents and Code folding `Extras.Rmd` 114 | * Presentations 115 | - **ioslidy_presentation.Rmd** Chose File > New > R Markdown > ioslidy presentation to create this presentation template. 116 | - **xaringan_presentation.Rmd** You will need to install the **xaringan** package. 117 | * Making tables using a function. This allows you to make the same table but with different data. A common example would be making a standard table for each species or each population in a dataset. [Report with Tables](https://github.com/RVerse-Tutorials/Rmarkdown-Tutorial/tree/master/Report_with_Tables) shows you how to do that. Start with the README file. 118 | 119 | ## Accessibility 120 | 121 | Knitting in RStudio by clicking the Knit button uses `rmarkdown::render()` which will automatically produce an html document that is more accessible than other ways that you might knit a R Markdown document. However you'll need to do some special things to add alt info to figure in the html, specifically add a figure caption. 122 | 123 | ### Adding figure alt text 124 | 125 | If you don't need to have figure captions or if you are ok with the figure legend and alt text being the same, they adding alt text for figures is quite easy. 126 | 127 | **Figure caption displayed and alt text will be the same** 128 | 129 | ```{r fig.cap="This will be the alt text"} 130 | plot(1:10) 131 | ``` 132 | 133 | **No figure caption displayed** 134 | 135 | Add this to the top of your Rmd (or save to a css file and put that in the yaml) and the figure caption will not show up in your html. 136 | 137 | ``` 138 | 143 | ``` 144 | 145 | **Use html** 146 | 147 | Another approach is to have R Markdown save your figures, and then insert those with html. Then you have full control over the caption, alt text and can add the longdesc tag also. 148 | 149 | ### Adding table captions 150 | 151 | You can use `caption=` with `knitr::kable()` to add captions. 152 | 153 | ```{r} 154 | knitr::kable(cars[,1:2], caption="This will be the Table caption") 155 | ``` 156 | 157 | **No table caption displayed** 158 | 159 | Add this to the top of your Rmd (or save to a css file and put that in the yaml) and the table caption will not show up in your displayed html but will still be there for accessibility. 160 | 161 | ``` 162 | 167 | ``` 168 | 169 | ### Accessibility resources 170 | https://r-resources.massey.ac.nz/rmarkdown/ 171 | 172 | **Latex (PDF)*** 173 | 174 | Making accessible PDFs is harder in LaTeX. You might look at the [tagpdf](https://www.ctan.org/pkg/tagpdf). 175 | 176 | Another option is to have R Markdown save the figures, and use LaTeX: 177 | 178 | ``` 179 | \begin{figure} 180 | \centering 181 | \includegraphics{fig1.png} 182 | \Description[short desc]{long description} 183 | \caption{the caption} 184 | \label{fig:fig1} 185 | \end{figure} 186 | ``` 187 | 188 | ## More Rmd uses 189 | 190 | * Websites: The workshop website is built off Rmd files. See the [website](https://rverse-tutorials.github.io/RWorkflow-NWFSC-2020/websites.html) tutorial to learn how to do this. It is super easy. 191 | * Online books using bookdown: Books [like this one](https://nwfsc-timeseries.github.io/atsa-labs/) for our time-series course are easy to make using Rmds. See the [bookdown](https://rverse-tutorials.github.io/RWorkflow-NWFSC-2020/bookdown.html) tutorial to learn how to do this. Again super easy. 192 | * Create a spiffy landing page for your repository: Like this one for our [MARSS package](https://nwfsc-timeseries.github.io/MARSS/). This is literally a couple clicks on GitHub (not sure if this is possible on GitLab). 193 | * A journal article repo. [Journal Article](https://github.com/RVerse-Tutorials/Journal_Article) This shows you a realistic repository for a journal article. I've cut out many paragraphs here and there to shorten it, but it is still has all the parts. The repository is a self-contained paper with all the data and the analyses are redone completely whenever Main.Rmd is re-knit. So if the data change, all the analyses will be updated. 194 | * Making tables using a function. This allows you to make the same table but with different data. A common example would be making a standard table for each species or each population in a dataset. [Report with Tables](https://github.com/RVerse-Tutorials/Rmarkdown-Tutorial/tree/master/Report_with_Tables) shows you how to do that. Start with the README file. 195 | 196 | ## Figure and Table numbering 197 | 198 | Automatic figures and table numbering for a paper or a report is a hassle with R Markdown. Here is my [solution](https://stackoverflow.com/a/47298632/10947238). The Journal Article repo uses this method. 199 | 200 | 201 | 202 | -------------------------------------------------------------------------------- /week9-data-wrangling.R: -------------------------------------------------------------------------------- 1 | ## ----setup, include=FALSE--------------------------------------------------------------- 2 | knitr::opts_chunk$set(echo = TRUE) 3 | 4 | 5 | ## ----message=FALSE, warning=FALSE------------------------------------------------------- 6 | library(dplyr) 7 | library(tidyr) 8 | library(ggplot2) 9 | 10 | 11 | ## --------------------------------------------------------------------------------------- 12 | 1:10 %>% sqrt() %>% mean() %>% round(digits=1) 13 | 14 | 15 | ## --------------------------------------------------------------------------------------- 16 | round(mean(sqrt(1:10)),digits=1) 17 | 18 | 19 | ## --------------------------------------------------------------------------------------- 20 | fun <- function(a=1, b=10){c(max(a), min(b))} 21 | a <- 2:10 22 | a %>% fun(a^2) 23 | 24 | 25 | ## --------------------------------------------------------------------------------------- 26 | a <- 3 27 | a %>% rnorm(n=a) 28 | a %>% rnorm() 29 | 30 | 31 | ## ----message=FALSE---------------------------------------------------------------------- 32 | library(microbenchmark) 33 | bm <- microbenchmark(1:10 %>% sqrt() %>% mean() %>% round(digits=1), round(mean(sqrt(1:10)),digits=1) ) 34 | ggplot2::autoplot(bm) 35 | 36 | 37 | ## --------------------------------------------------------------------------------------- 38 | fun <- function(x, cyl=1){ 39 | x %>% transform(new = mpg^cyl) %>% select(mpg, new) 40 | } 41 | 42 | 43 | ## --------------------------------------------------------------------------------------- 44 | df <- data.frame(mpg=runif(10, 10, 30)) 45 | fun(df, cyl=0.5) 46 | 47 | 48 | ## --------------------------------------------------------------------------------------- 49 | fun(mtcars[1:5,], cyl=0.5) 50 | 51 | 52 | ## --------------------------------------------------------------------------------------- 53 | head(mtcars) 54 | 55 | 56 | ## --------------------------------------------------------------------------------------- 57 | mtcars %>% select(mpg) 58 | 59 | 60 | ## --------------------------------------------------------------------------------------- 61 | mtcars %>% select(-mpg, -qsec, -gear, -cyl) 62 | 63 | ## --------------------------------------------------------------------------------------- 64 | mtcars %>% select(disp:qsec) 65 | 66 | 67 | ## --------------------------------------------------------------------------------------- 68 | mtcars %>% select(!disp:qsec) 69 | 70 | ## --------------------------------------------------------------------------------------- 71 | df %>% select(where(is.numeric)) 72 | 73 | 74 | ## --------------------------------------------------------------------------------------- 75 | mtcars %>% filter(cyl==4) 76 | 77 | 78 | ## --------------------------------------------------------------------------------------- 79 | mtcars %>% filter(cyl==4, hp>90) 80 | 81 | 82 | ## --------------------------------------------------------------------------------------- 83 | mtcars %>% 84 | summarize(mean.wt=mean(wt)) 85 | 86 | 87 | ## --------------------------------------------------------------------------------------- 88 | mtcars %>% 89 | summarize(mean.wt=mean(wt)) %>% 90 | round(digits=2) 91 | 92 | 93 | ## --------------------------------------------------------------------------------------- 94 | round(mean(mtcars$wt), digits=2) 95 | 96 | 97 | ## --------------------------------------------------------------------------------------- 98 | mtcars %>% 99 | summarize(mean.wt=mean(c(mpg, hp))) 100 | 101 | 102 | ## --------------------------------------------------------------------------------------- 103 | mean(c(mtcars$mpg, mtcars$hp)) 104 | 105 | 106 | ## --------------------------------------------------------------------------------------- 107 | mtcars %>% 108 | summarize(mean.wt=mean(mpg:hp)) 109 | 110 | 111 | ## --------------------------------------------------------------------------------------- 112 | mtcars[1,"mpg"]:mtcars[1,"hp"] 113 | 114 | 115 | ## --------------------------------------------------------------------------------------- 116 | mean(mtcars[1,"mpg"]:mtcars[1,"hp"]) 117 | 118 | 119 | ## --------------------------------------------------------------------------------------- 120 | mtcars %>% summarize_at(vars(mpg:hp), mean) 121 | 122 | 123 | ## --------------------------------------------------------------------------------------- 124 | mtcars %>% 125 | select(mpg:hp) %>% 126 | summarize_all(mean) 127 | 128 | ## --------------------------------------------------------------------------------------- 129 | apply(mtcars[,1:4],2,mean) 130 | 131 | 132 | ## --------------------------------------------------------------------------------------- 133 | df <- mtcars[,1:3]; df$label="test" 134 | df %>% summarize_all(mean) 135 | 136 | 137 | ## --------------------------------------------------------------------------------------- 138 | apply(df,2,mean) 139 | 140 | 141 | ## --------------------------------------------------------------------------------------- 142 | mtcars %>% 143 | filter(cyl==4) %>% 144 | select(mpg:hp) %>% 145 | summarize_all(mean) %>% 146 | round(digits=2) %>% 147 | paste(collapse=" -- ") 148 | 149 | 150 | ## --------------------------------------------------------------------------------------- 151 | df2 <- data.frame(id=paste0(rep("s",8),1:2), 152 | pop=paste0(rep("r",8),rep(1:2,each=4)), 153 | Week1=rnorm(8), Week2=rnorm(8), Week3=rnorm(8), Week4=rnorm(8)) 154 | head(df2) 155 | 156 | 157 | ## --------------------------------------------------------------------------------------- 158 | df2 %>% group_by(pop) %>% summarize_all(mean) 159 | 160 | 161 | ## --------------------------------------------------------------------------------------- 162 | apply(df2[df2$pop=="r1",3:6],2,mean) 163 | 164 | 165 | ## --------------------------------------------------------------------------------------- 166 | df2 %>% 167 | group_by(pop, id) %>% 168 | summarize(mean=mean(c(Week1, Week2, Week3, Week4))) 169 | 170 | 171 | ## --------------------------------------------------------------------------------------- 172 | df2 %>% group_by(pop) %>% 173 | select(where(is.numeric)) %>% 174 | summarize_all(mean) 175 | 176 | 177 | ## --------------------------------------------------------------------------------------- 178 | df2 %>% group_by(pop) %>% 179 | select(ends_with("2")) %>% 180 | summarize_all(mean) 181 | 182 | 183 | ## --------------------------------------------------------------------------------------- 184 | mtcars %>% 185 | select(mpg:wt) %>% 186 | mutate(wt.hp=wt/hp) 187 | 188 | 189 | ## --------------------------------------------------------------------------------------- 190 | fun <- function(x,y){fit <- lm(y~x); coef(fit)[1]} #return interept 191 | mtcars %>% 192 | group_by(carb) %>% 193 | summarize(lmm=fun(mpg,hp)) 194 | 195 | 196 | ## --------------------------------------------------------------------------------------- 197 | mtcars %>% 198 | group_by(carb) %>% 199 | mutate(lmm=fun(mpg,hp)) %>% 200 | select(mpg, hp, lmm) 201 | 202 | 203 | ## --------------------------------------------------------------------------------------- 204 | mtcars %>% 205 | select(mpg:wt) %>% 206 | mutate(mean=sqrt(wt)) 207 | 208 | 209 | ## --------------------------------------------------------------------------------------- 210 | mtcars %>% 211 | select(mpg:wt) %>% 212 | mutate(mean=mean(wt)) 213 | 214 | 215 | ## --------------------------------------------------------------------------------------- 216 | mtcars %>% 217 | select(mpg:wt) %>% 218 | mutate(mean1 = (wt+hp)/2, mean2=mean(c(wt,hp))) 219 | 220 | 221 | ## ----message=FALSE---------------------------------------------------------------------- 222 | bm <- microbenchmark( 223 | apply(mtcars,2,sum), 224 | summarize_all(mtcars, sum) 225 | ) 226 | ggplot2::autoplot(bm) 227 | 228 | 229 | ## ----message=FALSE---------------------------------------------------------------------- 230 | bm <- microbenchmark( 231 | mtcars[mtcars$cyl==4,], 232 | filter(mtcars, cyl==4), 233 | subset(mtcars, cyl==4) 234 | ) 235 | ggplot2::autoplot(bm) 236 | 237 | 238 | ## --------------------------------------------------------------------------------------- 239 | df <- subset(mtcars, select=c(mpg, wt, hp, carb)) 240 | df$model <- rownames(mtcars) 241 | head(df) 242 | 243 | 244 | ## --------------------------------------------------------------------------------------- 245 | fit <- lm(mpg ~ wt + hp, data=df) 246 | summary(fit) 247 | 248 | 249 | ## --------------------------------------------------------------------------------------- 250 | plot(df$mpg, col="red", ylim=c(0,200)) 251 | points(df$wt, col="green") 252 | points(df$hp, col="blue") 253 | 254 | 255 | ## --------------------------------------------------------------------------------------- 256 | plot(df$carb, df$mpg, col="red", ylim=c(0,200)) 257 | points(df$carb, df$wt, col="green") 258 | points(df$carb, df$hp, col="blue") 259 | 260 | 261 | ## --------------------------------------------------------------------------------------- 262 | df.long <- data.frame() 263 | a <- data.frame(model=df$model, val=df$mpg, name="mpg", carb=df$carb) 264 | df.long <- rbind(df.long, a) 265 | a <- data.frame(model=df$model, val=df$wt, name="wt", carb=df$carb) 266 | df.long <- rbind(df.long, a) 267 | a <- data.frame(model=df$model, val=df$hp, name="hp", carb=df$carb) 268 | df.long <- rbind(df.long, a) 269 | df.long 270 | 271 | 272 | ## --------------------------------------------------------------------------------------- 273 | ggplot(df.long, aes(x=model, y=val, col=name)) + geom_point() 274 | 275 | 276 | ## --------------------------------------------------------------------------------------- 277 | ggplot(df.long, aes(x=model, y=val, col=name)) + geom_point() + 278 | facet_wrap(~name) 279 | 280 | 281 | ## --------------------------------------------------------------------------------------- 282 | df.long2 <- 283 | pivot_longer( 284 | df, 285 | cols = c("mpg", "wt", "hp"), 286 | names_to = "name", 287 | values_to = "val" 288 | ) 289 | 290 | 291 | ## --------------------------------------------------------------------------------------- 292 | df.long2 293 | 294 | 295 | ## --------------------------------------------------------------------------------------- 296 | ggplot(df.long, aes(x=model, y=val, col=name)) + geom_point() + 297 | facet_wrap(~name) 298 | 299 | 300 | ## --------------------------------------------------------------------------------------- 301 | df.long$name <- factor(df.long$name, levels=c("mpg", "wt", "hp")) 302 | ggplot(df.long, aes(x=model, y=val, col=name)) + geom_point() + 303 | facet_wrap(~name) + 304 | theme(axis.text.x=element_blank()) 305 | 306 | 307 | ## --------------------------------------------------------------------------------------- 308 | pivot_wider( 309 | df.long, 310 | names_from = "name", 311 | values_from = "val" 312 | ) 313 | 314 | 315 | ## ----results="hide"--------------------------------------------------------------------- 316 | df.long %>% 317 | pivot_wider( 318 | names_from = "name", 319 | values_from = "val" 320 | ) 321 | 322 | -------------------------------------------------------------------------------- /week7-more-git.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Week 7: More Git" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 15 | library(kableExtra) 16 | dt <- data.frame("Compartmentalized", "Documented", "Extendible", "Reproducible", "Robust") 17 | kable(dt, col.names=NULL) %>% 18 | kable_styling(full_width = TRUE) %>% 19 | row_spec(1, bold = FALSE, color = "white", background = "blue") %>% 20 | column_spec(column = 1:5, width = "20%") 21 | ``` 22 | This week I will cover some more features of using Git, GitHub, and RStudio. Although I'll be using GitHub, the same workflow applies to GitLab. I am going to be using GitHub Desktop to interact with GitHub since I find that GitHub Desktop helps me deal with merge conflicts and reverts (getting rid of changes I have made). 23 | 24 | * What's a merge conflict and how to fix it 25 | * How to use branches 26 | * How to do a pull request to pull a branch into your master repository 27 | * How to 'go back in time' and get rid of changes 28 | * Working with issues in GitHub 29 | * How to create a release in GitHub 30 | * A workflow to minimize headaches 31 | 32 | I'll be illustrating this with this repo: https://github.com/eeholmes/MyNewPackage 33 | You can see a real-world example of this here on my MARSS package repo: 34 | https://github.com/nwfsc-timeseries/MARSS 35 | 36 | ## Merge conflicts 37 | 38 | Merge conflicts happen when there are changes to a file on your remote repository (GitHub or GitLab) but also changes to that same file on your local repository. Git doesn't know how to resolve the conflicting changes and needs your help. 39 | 40 | ### Resolving these with GitHub Desktop 41 | 42 | GitHub Desktop makes resolving these pretty easy. 43 | 44 | 1. If it tells you to fetch commits off GitHub, go ahead and do that. 45 | 2. Now try to Pull. It'll tell you that you have conflicts and give you options for what to do. 46 | 47 | ![GitHub Desktop merge conflict alert](images/git-merge-conflict-gh.png) 48 | 49 | * Click the 'x' and Git will alter `hello.R` and show where the conflicts are. You then edit `hello.R` in RStudio to fix the conflicts. 50 | * If you know what file you want to use, use the little arrow dropdown to use the file on GitHub or on your local machine. 51 | * Use Abort Merge to abandon the merge. Your changes to `hello.R` are still there. 52 | * Click on History, right click the commit and revert to get rid of it. All file changes that are part of that commit will disappear! You can revert the revert if needed. 53 | * Go into `hello.R` and fix the conflict. Git won't have marked it so it might be hard to find. 54 | 55 | ### Resolving these with Git in RStudio 56 | 57 | Unfortunately, when you hit 'Push' in the Git tab in RStudio, it will immediately change `hello.R` with the conflicts. RStudio won't give you the chance to abandon the merge or pick one of the files. 58 | 59 | But you can fix and then merge. 60 | 61 | * Open `hello.R` and get rid of all the merge conflict code (denoted with the ============ and >>>>>>>>>>>>>>>>). 62 | * The file will appear in the Git tab. 63 | * Click on the checkbox until a CHECK appears. Filled in square is not enough. You need the CHECK. 64 | * Commit the change. 65 | * Push. 66 | 67 | ## Working with branches 68 | 69 | Why use branches? 70 | 71 | * Let's say you have a function that works fine and you want to make a bunch of changes but don't want to break the old version. Work on a branch to sandbox your changes and merge back into master when done. 72 | * Let's say you want to try out an idea or new feature. Develop on a branch and merge into master when done. 73 | * Let's say you want to do a major revamp of your code, but you are worried that you might want to abandon this. Work on a branch. If you decide against the change, you just delete the branch. 74 | * Will your work break code? Make a branch. 75 | 76 | When you start, keep it simple. Use a branch for one file or two. Work on the file and then merge it back into master. Then get rid of the branch. It's not necessary to use branches but if you do a lot of coding or work on packages, then getting comfortable with them will help you out. 77 | 78 | ### Make a new branch in RStudio 79 | 80 | Click the new branch icon and give your branch a name. Give it an INFORMATIVE name. `tmp`, `foo` are bad. `hello_branch` is good as it tells what this branch is for (working on the `hello.R` file). 81 | ![new branch](images/new-branch.png) 82 | 83 | Now that you have a branch, it is critical that you pay attention to the Git tab and know where you are working. RStudio will remember what branch you are on. 84 | 85 | Let's make a change to `hello.R` on hello_branch, put to GitHub and see what the two branches look like. 86 | 87 | ### Pull request, merge our branch with master 88 | 89 | There are a few ways to do a pull request. 90 | 91 | * You can do it from GitHub Desktop. It'll just redirect you to GitHub however. 92 | 93 | * You can do it from GitHub. 94 | 95 | ![pull request from GitHub](images/pull-request-github.png) 96 | 97 | Once you have created the pull requests, you'll see that the pull request tab (in GitHub) shows that there is a request. 98 | 99 | * Click on the request. You have 2 options. 100 | * Close it (don't merge). If you close it, you can reopen it later. 101 | * Merge the request. 102 | 103 | * You have done the merge on GitHub. You still need to do a Pull to get that change into your local repository. 104 | 105 | * Delete your branch when you are done with it. All the history is saved. There is no reason keep branches that you are done with. 106 | 107 | ### Branch actions from GitHub Desktop 108 | 109 | The branch toolbar in GitHub Desktop let's keep branches up to date with each other. 110 | 111 | Let's say I am working on `littleforecast.R` in the master branch while working on `hello.R` in the hello_branch. I want to keep these synced up. 112 | 113 | * **Compare** I can compare branches and look at the differences. 114 | * **Merge into current branch** I can merge changes from one branch into another branch. It will let you see the changes before you decide to merge. 115 | * **Update from master** This immediately merge changes from master into your branch. It won't ask you. So you need to revert the change if you don't like it. 116 | 117 | This is similar to a pull request but happening locally. When a team is working on different branches, they would use pull requests. 118 | 119 | ### Branch actions from GitHub 120 | 121 | You can do the same actions from GitHub. 122 | 123 | ## Issues 124 | 125 | * Use the Issues in GitHub to enter any issues (bugs, feature changes, notes). 126 | * You can reference issues in your commits with # 127 | * Add code to your issue so you can easily recreate the problem 128 | 129 | ## Releases 130 | 131 | * The release or tag feature in GitHub will help you go back in time and document working states 132 | * Use a NEWS file to keep a notebook of all your changes. I use a standard format with BUGS, DOCUMENTATION, ENHANCEMENTS. It's really helpful for understanding what is happening with the code. 133 | 134 | ## Getting rid of changes you have made 135 | 136 | Say you made a change and you need to get rid of that. The temptation (for me) is to jump onto the Git command line and clobber my repository with `reset` and `revert` commands. Don't do this. Here are some strategies that will make this let prone to leaving your code a mess. 137 | 138 | ### Have you commited the changes yet? 139 | 140 | **No?** Easy click on the file in the Git panel in RStudio, right click, and click 'Revert'. Note this will take things all the way back to your last commit!! If you have been making a bunch of changes without committing those, then you are out of luck. 141 | 142 | **Yes?** Go to History in the GitHub Desktop window, click on the commit and click 'Revert'. This will get rid of all the changes that went with that commit. So if you changed multiple files, all those files will be reverted. If you have pushed the changes to GitHub, then you can push the revert and it'll show up on GitHub too. 143 | 144 | **Yes but you just want to revert one file in a multi-file commit?** Ok, you can do this at the Git command line, but I find that to be a huge time suck and in my early Git days, I sometimes left my repository with a horrible problem that I could not fix and had to completely rebuild my repo. Since I don't need to be a Git wizard, this is what I do when I want to go 'back in time' for a since file. 145 | 146 | Assuming you have already pushed the changes up to GitHub 147 | 148 | * Go to the repo on GitHub 149 | * Click 'commits' It's a little icon above your code with a clock with a counter-clockwise arrow. 150 | * Scroll to the commit where the file was in the state you want (one before the last bad commit). 151 | * On the right click the `< >` to browse your repo at the state in time where your file was ok. 152 | * Click on the file and copy the text. 153 | * Go back to RStudio, open the file, and paste in the text from when it was good. 154 | 155 | If you have not pushed the changes up to GitHub. 156 | 157 | * Now you have to go to the Git command line. Git tab in RStudio and then click the cog > Shell. 158 | * Note, in 9 times out of 10, I would push the commit to GitHub and then use the above copy/paste to avoid using the Git command line. I would find that much faster. 159 | 160 | Ok, here's the Git command to get a single file back. This works whether or not you have pushed to GitHub. The problem with this and why I don't do it is that I usually need to look at the file. So I am scrolling back through the status of my repo in the past until I find the status that I want. Then I stare a bit and think and think. Then get a coffee and think some more. Then I scroll back through the status of the repo in the past some more and THEN I do the copy and paste. It is rarely the case that I know exactly what commit that I need to get rid of---and even rarer that I want to go completely to a status in the past. 161 | 162 | * Open the Git bash shell 163 | * `git log` to find the commit hash (the long number) 164 | * `git checkout 1d0f8c2eb4e66db0a7123588ae2fad26a6338303~1 -- ./R/test.R` would reset test.R to one before that commit. This part `1d0f8c2eb4e66db0a7123588ae2fad26a6338303` is the bad commit hash and this part `~1` means what the file was like 1 commit before that. 165 | 166 | If you accidentally leave off the file name and Git says you have a detached head, use `git checkout master` to reattach your head. 167 | 168 | ## A workflow to minimize headaches 169 | 170 | ### Starting out 171 | 172 | * Don't use branches when you are just starting. Get used to committing and pulling without creating merge conflicts. 173 | * Get in the habit of always doing a Pull/Push before you start work in your project. 174 | 175 | ### Once you are experienced with GitHub 176 | 177 | Once doing commits and push/pulls is familiar and you are no longer messing up your repository or making merge conflicts, 178 | 179 | * Start using branches 180 | * Work on one branch at a time 181 | * Delete your branch when done 182 | * Once you start using multiple branches, be careful to keep them separate. Modifications to `file_xyz` should only be in one branch. 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /site_libs/jqueryui-1.11.4/jquery-ui.structure.min.css: -------------------------------------------------------------------------------- 1 | /*! jQuery UI - v1.11.4 - 2016-01-05 2 | * http://jqueryui.com 3 | * Copyright jQuery Foundation and other contributors; Licensed MIT */ 4 | 5 | .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}.ui-draggable-handle{-ms-touch-action:none;touch-action:none}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:0.1px;display:block;-ms-touch-action:none;touch-action:none}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable{-ms-touch-action:none;touch-action:none}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-sortable-handle{-ms-touch-action:none;touch-action:none}.ui-accordion .ui-accordion-header{display:block;cursor:pointer;position:relative;margin:2px 0 0 0;padding:.5em .5em .5em .7em;min-height:0;font-size:100%}.ui-accordion .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-icons .ui-accordion-icons{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-accordion-header-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;overflow:auto}.ui-autocomplete{position:absolute;top:0;left:0;cursor:default}.ui-button{display:inline-block;position:relative;padding:0;line-height:normal;margin-right:.1em;cursor:pointer;vertical-align:middle;text-align:center;overflow:visible}.ui-button,.ui-button:link,.ui-button:visited,.ui-button:hover,.ui-button:active{text-decoration:none}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:normal}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}input.ui-button::-moz-focus-inner,button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{overflow:hidden;position:absolute;top:0;left:0;padding:.2em;outline:0}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 0;white-space:nowrap;width:90%;overflow:hidden;text-overflow:ellipsis}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:20px;margin:-10px 0 0 0;padding:1px;height:20px}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:none;overflow:auto}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin-top:.5em;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:12px;height:12px;right:-5px;bottom:-5px;background-position:16px 16px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-menu{list-style:none;padding:0;margin:0;display:block;outline:none}.ui-menu .ui-menu{position:absolute}.ui-menu .ui-menu-item{position:relative;margin:0;padding:3px 1em 3px .4em;cursor:pointer;min-height:0;list-style-image:url("data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7")}.ui-menu .ui-menu-divider{margin:5px 0;height:0;font-size:0;line-height:0;border-width:1px 0 0 0}.ui-menu .ui-state-focus,.ui-menu .ui-state-active{margin:-1px}.ui-menu-icons{position:relative}.ui-menu-icons .ui-menu-item{padding-left:2em}.ui-menu .ui-icon{position:absolute;top:0;bottom:0;left:.2em;margin:auto 0}.ui-menu .ui-menu-icon{left:auto;right:0}.ui-progressbar{height:2em;text-align:left;overflow:hidden}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-progressbar-overlay{background:url("data:image/gif;base64,R0lGODlhKAAoAIABAAAAAP///yH/C05FVFNDQVBFMi4wAwEAAAAh+QQJAQABACwAAAAAKAAoAAACkYwNqXrdC52DS06a7MFZI+4FHBCKoDeWKXqymPqGqxvJrXZbMx7Ttc+w9XgU2FB3lOyQRWET2IFGiU9m1frDVpxZZc6bfHwv4c1YXP6k1Vdy292Fb6UkuvFtXpvWSzA+HycXJHUXiGYIiMg2R6W459gnWGfHNdjIqDWVqemH2ekpObkpOlppWUqZiqr6edqqWQAAIfkECQEAAQAsAAAAACgAKAAAApSMgZnGfaqcg1E2uuzDmmHUBR8Qil95hiPKqWn3aqtLsS18y7G1SzNeowWBENtQd+T1JktP05nzPTdJZlR6vUxNWWjV+vUWhWNkWFwxl9VpZRedYcflIOLafaa28XdsH/ynlcc1uPVDZxQIR0K25+cICCmoqCe5mGhZOfeYSUh5yJcJyrkZWWpaR8doJ2o4NYq62lAAACH5BAkBAAEALAAAAAAoACgAAAKVDI4Yy22ZnINRNqosw0Bv7i1gyHUkFj7oSaWlu3ovC8GxNso5fluz3qLVhBVeT/Lz7ZTHyxL5dDalQWPVOsQWtRnuwXaFTj9jVVh8pma9JjZ4zYSj5ZOyma7uuolffh+IR5aW97cHuBUXKGKXlKjn+DiHWMcYJah4N0lYCMlJOXipGRr5qdgoSTrqWSq6WFl2ypoaUAAAIfkECQEAAQAsAAAAACgAKAAAApaEb6HLgd/iO7FNWtcFWe+ufODGjRfoiJ2akShbueb0wtI50zm02pbvwfWEMWBQ1zKGlLIhskiEPm9R6vRXxV4ZzWT2yHOGpWMyorblKlNp8HmHEb/lCXjcW7bmtXP8Xt229OVWR1fod2eWqNfHuMjXCPkIGNileOiImVmCOEmoSfn3yXlJWmoHGhqp6ilYuWYpmTqKUgAAIfkECQEAAQAsAAAAACgAKAAAApiEH6kb58biQ3FNWtMFWW3eNVcojuFGfqnZqSebuS06w5V80/X02pKe8zFwP6EFWOT1lDFk8rGERh1TTNOocQ61Hm4Xm2VexUHpzjymViHrFbiELsefVrn6XKfnt2Q9G/+Xdie499XHd2g4h7ioOGhXGJboGAnXSBnoBwKYyfioubZJ2Hn0RuRZaflZOil56Zp6iioKSXpUAAAh+QQJAQABACwAAAAAKAAoAAACkoQRqRvnxuI7kU1a1UU5bd5tnSeOZXhmn5lWK3qNTWvRdQxP8qvaC+/yaYQzXO7BMvaUEmJRd3TsiMAgswmNYrSgZdYrTX6tSHGZO73ezuAw2uxuQ+BbeZfMxsexY35+/Qe4J1inV0g4x3WHuMhIl2jXOKT2Q+VU5fgoSUI52VfZyfkJGkha6jmY+aaYdirq+lQAACH5BAkBAAEALAAAAAAoACgAAAKWBIKpYe0L3YNKToqswUlvznigd4wiR4KhZrKt9Upqip61i9E3vMvxRdHlbEFiEXfk9YARYxOZZD6VQ2pUunBmtRXo1Lf8hMVVcNl8JafV38aM2/Fu5V16Bn63r6xt97j09+MXSFi4BniGFae3hzbH9+hYBzkpuUh5aZmHuanZOZgIuvbGiNeomCnaxxap2upaCZsq+1kAACH5BAkBAAEALAAAAAAoACgAAAKXjI8By5zf4kOxTVrXNVlv1X0d8IGZGKLnNpYtm8Lr9cqVeuOSvfOW79D9aDHizNhDJidFZhNydEahOaDH6nomtJjp1tutKoNWkvA6JqfRVLHU/QUfau9l2x7G54d1fl995xcIGAdXqMfBNadoYrhH+Mg2KBlpVpbluCiXmMnZ2Sh4GBqJ+ckIOqqJ6LmKSllZmsoq6wpQAAAh+QQJAQABACwAAAAAKAAoAAAClYx/oLvoxuJDkU1a1YUZbJ59nSd2ZXhWqbRa2/gF8Gu2DY3iqs7yrq+xBYEkYvFSM8aSSObE+ZgRl1BHFZNr7pRCavZ5BW2142hY3AN/zWtsmf12p9XxxFl2lpLn1rseztfXZjdIWIf2s5dItwjYKBgo9yg5pHgzJXTEeGlZuenpyPmpGQoKOWkYmSpaSnqKileI2FAAACH5BAkBAAEALAAAAAAoACgAAAKVjB+gu+jG4kORTVrVhRlsnn2dJ3ZleFaptFrb+CXmO9OozeL5VfP99HvAWhpiUdcwkpBH3825AwYdU8xTqlLGhtCosArKMpvfa1mMRae9VvWZfeB2XfPkeLmm18lUcBj+p5dnN8jXZ3YIGEhYuOUn45aoCDkp16hl5IjYJvjWKcnoGQpqyPlpOhr3aElaqrq56Bq7VAAAOw==");height:100%;filter:alpha(opacity=25);opacity:0.25}.ui-progressbar-indeterminate .ui-progressbar-value{background-image:none}.ui-selectmenu-menu{padding:0;margin:0;position:absolute;top:0;left:0;display:none}.ui-selectmenu-menu .ui-menu{overflow:auto;overflow-x:hidden;padding-bottom:1px}.ui-selectmenu-menu .ui-menu .ui-selectmenu-optgroup{font-size:1em;font-weight:bold;line-height:1.5;padding:2px 0.4em;margin:0.5em 0 0 0;height:auto;border:0}.ui-selectmenu-open{display:block}.ui-selectmenu-button{display:inline-block;overflow:hidden;position:relative;text-decoration:none;cursor:pointer}.ui-selectmenu-button span.ui-icon{right:0.5em;left:auto;margin-top:-8px;position:absolute;top:50%}.ui-selectmenu-button span.ui-selectmenu-text{text-align:left;padding:0.4em 2.1em 0.4em 1em;display:block;line-height:1.4;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default;-ms-touch-action:none;touch-action:none}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider.ui-state-disabled .ui-slider-handle,.ui-slider.ui-state-disabled .ui-slider-range{filter:inherit}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-spinner{position:relative;display:inline-block;overflow:hidden;padding:0;vertical-align:middle}.ui-spinner-input{border:none;background:none;color:inherit;padding:0;margin:.2em 0;vertical-align:middle;margin-left:.4em;margin-right:22px}.ui-spinner-button{width:16px;height:50%;font-size:.5em;padding:0;margin:0;text-align:center;position:absolute;cursor:default;display:block;overflow:hidden;right:0}.ui-spinner a.ui-spinner-button{border-top:none;border-bottom:none;border-right:none}.ui-spinner .ui-icon{position:absolute;margin-top:-8px;top:50%;left:0}.ui-spinner-up{top:0}.ui-spinner-down{bottom:0}.ui-spinner .ui-icon-triangle-1-s{background-position:-65px -16px}.ui-tabs{position:relative;padding:.2em}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:0;margin:1px .2em 0 0;border-bottom-width:0;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav .ui-tabs-anchor{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-active{margin-bottom:-1px;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor,.ui-tabs .ui-tabs-nav li.ui-state-disabled .ui-tabs-anchor,.ui-tabs .ui-tabs-nav li.ui-tabs-loading .ui-tabs-anchor{cursor:text}.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-active .ui-tabs-anchor{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:none}.ui-tooltip{padding:8px;position:absolute;z-index:9999;max-width:300px;-webkit-box-shadow:0 0 5px #aaa;box-shadow:0 0 5px #aaa}body .ui-tooltip{border-width:2px} -------------------------------------------------------------------------------- /week6-more-packages.Rmd: -------------------------------------------------------------------------------- 1 | --- 2 | title: "Week 6: Advanced package topics" 3 | output: 4 | html_document: 5 | toc: true 6 | include: 7 | after_body: footer.html 8 | --- 9 | 10 | ```{r setup, include=FALSE} 11 | knitr::opts_chunk$set(echo = TRUE) 12 | ``` 13 | 14 | ```{r echo=FALSE, message=FALSE, warning=FALSE} 15 | library(kableExtra) 16 | dt <- data.frame("Compartmentalized", "Documented", "Extendible", "Reproducible", "Robust") 17 | kable(dt, col.names=NULL) %>% 18 | kable_styling(full_width = TRUE) %>% 19 | row_spec(1, bold = FALSE, color = "white", background = "blue") %>% 20 | column_spec(column = 1:5, width = "20%") 21 | ``` 22 | This week I will cover more advanced topics regarding R packages: 23 | 24 | * How to use the "check" feature to find problems in your package. 25 | * How to write a vignette for your package. 26 | * How to write print and plot functions for your objects. 27 | * Using pkgdown to make a website for your package. 28 | 29 | If/when you want to go into R packaging in more depth, work through the material from this [R package workshop material](https://combine-australia.github.io/r-pkg-dev/). You've seen much of this material so it should be somewhat familiar. See also Hadley Wickham's book [R Packages](http://r-pkgs.had.co.nz/). 30 | 31 | The repository that I used to demo these features is here: 32 | https://github.com/eeholmes/MyNewPackage 33 | 34 | ## Checking your package 35 | 36 | Just use the RStudio Check in the Build tab. You'll have many issues (most likely). Plug away at each one until you pass with no errors or warnings. Don't ignore Notes either. They are sometimes more serious than the errors and warnings. 37 | 38 | If R asks you to update packages, and then proceeds to fail at installation because of a warning that a package was built under a later R version than you have on your computer, use 39 | ``` 40 | Sys.setenv(R_REMOTES_NO_ERRORS_FROM_WARNINGS=TRUE) 41 | ``` 42 | 43 | 44 | ## Creating print and plot methods for your objects 45 | 46 | ### Make your output an object 47 | 48 | ``` 49 | littleforecast <- function(data, nyears=10){ 50 | fit <- forecast::auto.arima(data) 51 | fc <- forecast::forecast(fit, h = nyears) 52 | ggplot2::autoplot(fc) 53 | class(fit) <- c("foo", class(fit)) 54 | return(fit) 55 | } 56 | ``` 57 | 58 | ### print method 59 | 60 | ``` 61 | #' Prints foo object 62 | #' 63 | #' prints a foo object returned from littlefunction(). 64 | #' 65 | #' @param x foo object 66 | #' @param ... Not used 67 | #' @method print foo 68 | #' @export 69 | print.foo <- function(x, ...) { 70 | cat("Hello there") 71 | } 72 | ``` 73 | 74 | ### plot method 75 | 76 | ``` 77 | #' Plots foo object 78 | #' 79 | #' Plots foo object. 80 | #' 81 | #' @param x An foo object. 82 | #' @param ... Not used. 83 | #' @method plot foo 84 | #' @export 85 | plot.foo <- function(x, ...) { 86 | plot(1:10) 87 | } 88 | ``` 89 | 90 | Note, `plot()` is part of the graphics package so you need to add that to Imports in your DESCRIPTION file. Our Imports line is now: 91 | 92 | ``` 93 | Imports: forecast, graphics 94 | ``` 95 | 96 | ### Add your methods to your namespace 97 | 98 | ``` 99 | S3method(print,foo) 100 | S3method(plot,foo) 101 | ``` 102 | 103 | ### Example 104 | 105 | Install and restart MyNewPackage. 106 | 107 | ``` 108 | fit=littleforecast(WWW2) 109 | fit 110 | plot(fit) 111 | ``` 112 | 113 | 114 | ## Writing a vignette 115 | 116 | Doing this in RStudio is easy. See [rmarkdown vignette chapter](https://bookdown.org/yihui/rmarkdown-cookbook/package-vignette.html) and [Hadley's vignette chapter](http://r-pkgs.had.co.nz/vignettes.html) for more info. 117 | 118 | ### Making the vignette 119 | 120 | Manually 121 | 122 | * Make a vignettes folder at the base level (same level as the R folder) 123 | * Create a new vignette file from a template. RStudio > File > New > R Markdown > From Template > Vignette 124 | * Save in vignettes folder 125 | * Change the title in the 2 places in the yaml at the top. 'yaml' is between the `---` fences. 126 | * Add the following 2 lines to your DESCRIPTION file: 127 | 128 | ``` 129 | Suggests: knitr, rmarkdown 130 | VignetteBuilder: knitr 131 | ``` 132 | 133 | Or use a helper function: 134 | 135 | ``` 136 | devtools::use_vignette("my-vignette") 137 | ``` 138 | 139 | or 140 | 141 | ``` 142 | usethis::use_vignette("MyNewPackage") 143 | ``` 144 | 145 | ### Testing your vignette 146 | 147 | Open your vignette file and click the Knit button. 148 | 149 | ### Getting your vignette to show up 150 | 151 | Once you have your vignettes in the `vignettes` folder, you'l like to be able to build them and have them appear when you type `browseVignettes("MyNewPackage")`. This will not work. In fact, RStudio seems to actively hinders this workflow. 152 | 153 | Vignettes can take a long time to build and by default when R builds a package from source (which is what Install and Restart on the build tab does), it does not re-make your vignettes. You can make RStudio re-make your vignettes in the `vignettes` folder (if the Rmd file changes) using Tools > Project Options > Build Tools > Generate documentation with Roxygen > Configure and clicking the vignettes check-box. But this will not get your vignettes loaded when you click Install and Restart on the Build tab (`browseVignettes()` still won't work). 154 | 155 | So how does R know about your vignettes when it is building from source (i.e. from Install and Restart in the Build tab in RStudio)? It needs the vignette files (.Rmd, .R and .html) in the `inst/doc` folder. How do you get them there? You have to put them there. 156 | 157 | That's easy. I'll just put them there whenever I change or add vignettes. Unfortunately, the default RStudio default behavior is to delete the whole `inst/doc` folder whenever you click Check (package) in the Build tab. It's happening because the default is to use `devtools::check()` and there is no way to set `devtools::check(vignettes=FALSE)`. To stop RStudio from deleting `inst/doc` on package checking, uncheck the `use devtools package functions if available` box. You may also want to add `--no-manual` to the R CMD Check options box since that is the default for `devtools::check()`. 158 | 159 | 160 | This is my vignette workflow: 161 | 162 | * Create the `vignette` folder and add vignette Rmds to it using the R Markdown vignette template in RStudio. 163 | * Create the `inst` folder in my package at the base level (same level as the R folder). 164 | * Edit my vignette Rmd and use the Knit button to preview. 165 | * When I am done, run the following code to update the vignette files and copy to the `inst/doc` folder. 166 | 167 | ``` 168 | tools::buildVignettes(dir = ".", tangle=TRUE) 169 | dir.create("inst/doc") 170 | file.copy(dir("vignettes", full.names=TRUE), "inst/doc", overwrite=TRUE) 171 | ``` 172 | 173 | Once your vignette files are in `inst/doc`, Install and Restart button will add the vignettes to your package and `install_github()` will have them too. 174 | 175 | **Careful, RStudio `Check` in the Build tab will delete the `inst/doc` folder and not recreate it.** So always check that `inst/doc` not been trashed and **uncheck** the `use devtools package functions` checkbox on the Build > More > Configure Build Tools... window. You will most likely also want to add `--no-manual` to the `R CMD check additional options` box. 176 | 177 | 178 | ## **pkgdown** 179 | 180 | [pkgdown](https://pkgdown.r-lib.org/articles/pkgdown.html) makes it easy to make nice webpages for your packages. 181 | 182 | 183 | ## Depends versus Imports 184 | 185 | **@Depends** These packages that will be loaded when your package is loaded. So if you have **gplot2** in @Depends, like above, then the user automatically can use **ggplot2** functions without issuing the command `library(ggplot2)`. 186 | 187 | **@Imports** Are required for the package functions, but the user will not have access to the functions without calling `library(...)`. In your package, you will use `::` to access the functions from the packages on the @Imports line. *Most of your package dependencies will be here.* 188 | 189 | To limit the number of headaches that users face when trying to install your package, use as few packages on your @Depends and @Imports lines in DESCRIPTION file as possible. If your package does not need the package to work, then put the package on @Suggests. 190 | 191 | I have R packages that are mainly for my personal use. I use the package to make sure I have access to the various packages that I'll be using. So for example, if I am doing work on my sardine papers, I have set of packages that I use. When I issue the command `library(SardineForecast)` a bunch of packages are loaded. This makes it handy for me, but all those dependencies makes it a huge hassle to install the package from GitHub for my collaborators (and even a hassle for me to install from GitHub). Huge Hassle. Invariable one of the 15 packages that I need will itself have a dependency that won't load and then I have to debug that. If I need collaborators, who are on different operating systems and various versions of R to install it, it's a suffer-fest. 192 | 193 | For my MARSS package, I have only 3 non-base dependencies in the @Imports line and nothing on the @Depends line besides R. The imports are KFAS, mvtnorm, and nlme. Then on the @Suggests line, I have a bunch of packages that are used in the vignettes. MARSS is easy to install from GitHub (though it is also hosted on CRAN). 194 | 195 | **What should you put on your Depends and Imports lines?** 196 | 197 | First off, when you are starting, don't worry too much about this. Just add packages that are needed as you work on your functions. 198 | 199 | * ALWAYS use `::` to use functions from other packages in your package functions. Seriously. You will save yourself so many headaches down the road by being able to search for `xyzpackage::` to find all that packages functions. Why? Trust me, one day you will want to swap out packages or remove dependencies. Note, this can be a hassle with functions like `ggplot()` which use functions within their calls and you have to use `::` everywhere. Like so 200 | ```{r eval=FALSE} 201 | ggplot2::ggplot(df) + 202 | ggplot2::geom_point(ggplot2::aes(gp, y)) 203 | ``` 204 | Arg. Another example is say a GAM call: 205 | ```{r eval=FALSE} 206 | mgcv::gam(a ~ mgcv::s(b), data=df) 207 | ``` 208 | But this is just for your package functions. In your scripts, you'd probably use a `library()` call. 209 | 210 | * Never ever use `library()` in a function! Use `xyzfunction::function`. Sure use `library()` in your scripts, but never in a package function. When you add a function from a new package to your function, add those packages to @Depends or @Imports in your DESCRIPTION file as you go along. 211 | 212 | * Every so often check that you don't have packages on @Depends and @Imports that you don't use. Just do a Edit > Find in Files... search for `xyzpackage::` to find out if you are still using `xyzpackage`. 213 | 214 | * How do you know if you forgot a dependency or forgot a `::` somewhere? Two ways: 215 | 216 | 1. Do Session > Restart R to close all your loaded packages. Then load your package with `library(yourpackagename)` and try your functions. Things will fail if you have a package in @Imports but forgot a `::` somewhere. 217 | 2. From the Build tab, use More > Check Package. That should show package dependency errors (plus a whole slew of other problems for you to work through). 218 | 219 | ## Styling your code 220 | 221 | You should stick with a uniform style guide to make your code easier to follow. I use the tidyverse style guide with the [**styler** R package](https://www.tidyverse.org/blog/2017/12/styler-1.0.0/). **styler** has an RStudio Addin which does all the work of styling my code for me. Install the package, restart RStudio, and then go to Tools > Addins > Browse Addins. Scroll down to styler, and select the file(s), you want to style. 222 | 223 | ## Byte Compile 224 | 225 | Adding this line to your DESCRIPTION file can really speed up your code. This is one of the advantages of putting your functions in a package. It can actually make your functions faster. 226 | 227 | ``` 228 | ByteCompile: TRUE 229 | ``` 230 | 231 | --------------------------------------------------------------------------------