-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
62 lines (45 loc) · 1.77 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
---
output:
md_document:
variant: markdown_github
---
[![Travis-CI Build Status](https://travis-ci.org/nutterb/sillylogic.svg?branch=master)](https://travis-ci.org/nutterb/sillylogic)
[![Coverage Status](https://img.shields.io/coveralls/nutterb/sillylogic.svg)](https://coveralls.io/r/nutterb/sillylogic?branch=master)
# sillylogic
Emote via Logical Constants
Inspired by the [discussion on Twitter](https://twitter.com/michaelhoffman/status/630420081042849792), `sillylogic` provides some fun alternatives to use in place of `TRUE` and `FALSE`. Most famously:
```{r}
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.
```{r}
class(x$letter)
```
## Available Logical Representations
```{r, echo=FALSE, results='asis'}
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.
```{r}
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)
```