# loading libraries library(png) library(knitr) library(grid) library(ggplot2) # options opts_chunk$set(cache = TRUE, echo = FALSE) opts_chunk$set(cache.path = '/tmp/') # auxiliary function plot.png <- function(filename) { img <- readPNG(paste0(filename, '.png')) g <- rasterGrob(img, interpolate = TRUE) qplot(dim(img)[1] / 2, dim(img)[2] / 2) + xlim(c(1, dim(img)[1])) + ylim(c(1, dim(img)[2])) + geom_point() + annotation_custom(g, xmin=-Inf, xmax=Inf, ymin=-Inf, ymax=Inf) + theme_void() }
In my experience, statistical model code always consists of pretty much the same:
objects that hold observations, constants, etc.
functions that define the model
functions that plot results
With this package, I am attempting to establish a few patterns in my code, so that it becomes easier to read, debug, and modify. I have created the following virtual reference classes:
plot.png('basic')
plot.png('daemon')
plot.png('strategy')
plot.png('parameters')
plot.png('factory')
plot.png('plotter')
ggplot
, I wrote an
offspring of the Plotter class.plot.png('ggplotter')
plot.png('random')
Here is how these classes connect.
plot.png('classes')
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.