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)
all_silly <- getNamespaceExports("sillylogic") all_silly <- all_silly[!all_silly == "surprise_me"] silly <- sapply(all_silly, function(l) eval(parse(text = l))) sillyTRUE <- sort(names(silly[silly])) sillyFALSE <- sort(names(silly[!silly])) maxlength <- max(length(sillyTRUE), length(sillyFALSE)) sillyTRUE <- c(sillyTRUE, rep("", maxlength - length(sillyTRUE))) sillyFALSE <- c(sillyFALSE, rep("", maxlength - length(sillyFALSE))) Silly <- cbind(sillyTRUE, sillyFALSE) colnames(Silly) <- c("TRUE", "FALSE") knitr::kable(Silly)
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) y <- data.frame(letter = letters[1:10], stringsAsFactors = surprise_me()) class(y$letter)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.