-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME.Rmd
More file actions
74 lines (56 loc) · 2.33 KB
/
README.Rmd
File metadata and controls
74 lines (56 loc) · 2.33 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
---
output:
github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
library(postlogic)
```
# `postlogic` <img src="man/figures/logo.png" align="right" height=140/>
[](https://travis-ci.org/RDocTaskForce/postlogic)
[](https://codecov.io/github/RDocTaskForce/postlogic?branch=master)
[](https://cran.r-project.org/package=postlogic)
[](https://www.tidyverse.org/lifecycle/#experimental)
The goal of postlogic is to allow natural flowing logic statements.
## Installation
You can install the released version of postlogic from [CRAN](https://CRAN.R-project.org) with:
``` r
install.packages("postlogic")
```
## If/Otherwise
The if/otherwise instruction allows for simple logic to follow a statement
to make it conditional. The `%if%` can be used alone to make an action conditional.
```{r example}
verbose <- TRUE
message("Hello there") %if% verbose
```
When combined with the `%otherwise%` statement it allows for an alternate.
```{r angry}
mood <- "calm"
message("How dare you!") %if% (mood == 'angry') %otherwise%
message("Everything is fine.")
mood <- 'angry'
message("How dare you!") %if% (mood == 'angry') %otherwise%
message("Everything is fine.")
```
## Unless/Then
The `%unless%` operator is essentially the negation of `%if%`.
So when a statement is postfixed by an `%unless%` statement it will happen
unless the proposition returns `TRUE`. The alternating operator for
`%unless%` is `%then%`.
```{r}
mood <- 'calm'
message("Everything is fine.") %unless% (mood == 'angry') %then%
message("How dare you!")
```
This example is the same effect as the statements in the previous example.
## Documentation
The `postlogic` package is developed by the R Documentation Task Force, an
[R Consortium](https://www.r-consortium.org)
[Infrastructure Steering Committee working group](https://www.r-consortium.org/projects/isc-working-groups).