Skip to content

Instantly share code, notes, and snippets.

View mfoos's full-sized avatar

M. Foos mfoos

  • Boston, MA
View GitHub Profile
@mfoos
mfoos / solution_to_lineplot.R
Created March 28, 2018 23:31
Keeping errorbars solid while showing color AND linetype in the legend for lines in ggplot2
library(ggplot2)
set.seed(1)
test_df <- data.frame(models = rep(paste("Model", LETTERS[1:3]), 3),
x = c(rep(1, 3),
rep(2, 3),
rep(3, 3)),
y = c(1:3,1:3+1+rnorm(3,0,.2),1:3+2)+rnorm(3,0,.3))
test_df$ymax <- test_df$y + .3
test_df$ymin <- test_df$y - .3
@mfoos
mfoos / env_fxn_example.R
Last active January 7, 2020 15:45
Accessing private closure in R package
# Goal: To have a function that package users can call to set a variable that
# will be used to create a closure. The problem with the "problem" code
# is that it exposes the created function (private_function) to the user inappropriately.
############################ Problem
# a function in my package
user_calls <- function(string){
private_function <<- function(){
print(string)