Skip to content

Instantly share code, notes, and snippets.

@RyanHope
Created February 19, 2015 17:55
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 RyanHope/1468a2eda4b50f0fcbf9 to your computer and use it in GitHub Desktop.
Save RyanHope/1468a2eda4b50f0fcbf9 to your computer and use it in GitHub Desktop.
require(data.table)
d <- data.table(foo=c(0,1,2,3,4),bar=c(5,6,7,8,9))
f1 <- function(a, b) {
(a**b)%%2
}
f2 <- function(d, a, b) {
as.logical(f1(d[,a,with=F],d[,b,with=F]))
}
f2(d, "foo", "bar")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment