Emote via Logical Constants
Inspired by the discussion on Twitter, sillylogic
provides some fun alternatives to use in place of TRUE
and FALSE
. Most famously:
devtools::install_github("nutterb/sillylogic")
library(sillylogic)
x <- data.frame(letter = letters[1:10],
stringsAsFactors = HELLNO)
Which ensures that strings are not converted to factors when the data frame is assigned.
class(x$letter)
## [1] "character"
TRUE | FALSE |
---|---|
COUNTMEIN | ASIF |
HELLYES | HELLNO |
WHYNOT | NO |
YES | NOTHANKS |
YESPLEASE | NOWAY |
And for those who like to live a little dangerously, feel free to use the surprise_me
function.
set.seed(2)
x <- data.frame(letter = letters[1:10],
stringsAsFactors = surprise_me())
class(x$letter)
## [1] "factor"
y <- data.frame(letter = letters[1:10],
stringsAsFactors = surprise_me())
class(y$letter)
## [1] "character"