library(knitr) opts_chunk$set(fig.width=8, fig.height=6)
I have been tasked with coming up with a convenient method for digesting the
results of a SWIM model run. I think the best thing to do is to create a series
of helper functions that will create plots or calculate metrics on tables pulled
directly from the database. I have wrapped these functions in an Rpackage that I
am calling swimr
.
library(swimr)
The package relies on dplyr
, ggplot2
, and other modern R packages. These
should be installed by default, but I use them for lots of things so I'll load
them here.
library(dplyr) library(tidyr) library(ggplot2)
One advantage of the dplyr
package is that it can work on the SQLite database
directly. For more information, see the dplyr
vignette.
db_path <- "~/Documents/projects/swim/MFhousing.db" db <- src_sqlite(db_path) db
The functions have been written in such a way that they can aggregate to MPO, State, or County. Additionally, the user can select a set of those fields to show.
facet <- "COUNTY" counties <- c("Multnomah", "Washington", "Clackamas")
The user creates a plot using an RMarkdown template included in the package. From inside RStudio,
New .Rmd
Templates>
Single Scenario
or Compare Scenarios
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.