Skip to content

Instantly share code, notes, and snippets.

@PirateGrunt
Created May 7, 2013 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PirateGrunt/5529844 to your computer and use it in GitHub Desktop.
Save PirateGrunt/5529844 to your computer and use it in GitHub Desktop.
Examples of how to get ggplot and lm style function calls.
someFunction = function(y, data = NULL)
{
arguments <- as.list(match.call())
y = eval(arguments$y, data)
sum(y)
}
myData = data.frame(A = c(1,2,3), B = c(10,9,8))
someFunction(A, data=myData)
someFunction(B, data=myData)
someFunction(A)
X = c(1,2,3,4,5,6)
someFunction(X)
someFunction(X, data=myData)
A = c(1,2)
someFunction(A)
someFunction(A, data=myData)
someFunction("A", data=myData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment