Getting started: The link here has all you need to get started with R and software to edit scripts (Rstudio).
R and hydrology: Blog with a comprehensive list of links is here.
R and reproducibility
As noted by Uri Simonsohn in this blog, “R has some reproducibility problems”. The individual packages central to most scripts often change over time, so full reproducibility requires that you use the same versions of those packages, not just the same packages.
Fortunately, there is a solution: the “groundhog” library, which has you specify which date should be used as the baseline for all packages. Specifics between ____ below are copied from the Simonsohn blog:
So instead of this:
library('dplyr')u do this:
So, my new scripts now start with something like this:
When you use
groundhog.library()to ask for a package you don’t have, it gets installed automatically, and saved alongside any existing versions of it. That’s convenient.
R scripts with tips and tricks
Plots, including sub and superscripts in axis titles. Plotting in R is easy, with some tricky bits in formatting axis titles…
htmlTable example. htmlTable lets you put the results you generate in R directly into an html format, which you then convert to word format. No more re-entering data into a Word document! To import into Word: save the table “mytableout” you created in the Example by using this code in R:
Then open the html file in Libre Office, then copy and paste into Word. Annoying, I know!
Plot gallery with code on how to create them using R’s ggplot package.
Barplots with base graphics.
Summary sheet for data management with dply, tidyr.
Hydrologic analysis in R
Hydroinformatics course with examples