This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |