Skip to content

Instantly share code, notes, and snippets.

View brodieG's full-sized avatar

Brodie Gaslam brodieG

View GitHub Profile
list(system=c("browser",
"device",
"dvipscmd",
"mailer",
"pager",
"pdfviewer",
"pkgType",
"printcmd",
"HTTPUserAgent",
"texi2dvi",
@brodieG
brodieG / ensure_alike.R
Last active August 29, 2015 14:13
Using `alike` with `ensurer`
# Packages
library(devtools)
install_github("smbache/ensurer")
install_github("brodieg/alike")
library(ensurer)
library(alike)
library(magrittr)
set.seed(1)
DT[
id %in% 200:300,
.(reg.val = sum(value)),
by=region
][
reg.val > 0,
range(reg.val)
]
@brodieG
brodieG / data.table.standard.eval.R
Last active April 8, 2020 11:02
Corner Cases With Non-Standard Evaluation in data.table
# Because there is no way to tell data.table
# "interpret this variable as a column name", it's possible to come up
# with corner cases. I'll grant these are unlikely to occur in day
# to day use, but any function that uses `data.table` must account for
# them
# Low odds, and yes, there are workarounds, but this is
# what I mean by you have to think carefully to avoid
# corner cases
@brodieG
brodieG / setOldClassProbs.R
Last active August 29, 2015 14:04
Test setOldClass Issues
library(devtools)
install_github("pckgA", "brodieg") # defines old class "file" and class union "fileOrNULL" == c("file", "NULL")
install_github("pckgB", "brodieg") # defines old class "file", and nothing else
library(pckgA)
makeDummy() # from pckgA, instantiates a class with a "fileOrNULL" slot, placing a temp file S3 object in the slot
library(pckgB)
makeDummy() # this fails now