Skip to content

Instantly share code, notes, and snippets.

@aammd
Created March 10, 2017 09:30
Show Gist options
  • Save aammd/f566a3eafc6ee293d234b32812f3b2bb to your computer and use it in GitHub Desktop.
Save aammd/f566a3eafc6ee293d234b32812f3b2bb to your computer and use it in GitHub Desktop.
plotting with a function factory
rmax <- function(rm, baserate){
force(rm)
force(baserate)
function(x) {
rm * x / (
(rm / baserate) + x
)
}
}
library(dplyr)
library(ggplot2)
data_frame(x = 0:90,
y = 0, 1) %>%
ggplot(aes(x = x, y = y)) +
stat_function(fun = rmax(0.7, 0.3))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment