# lest 1.1.0 (CRAN)

Vectorised Nested if-else Statements Similar to CASE WHEN in 'SQL'

[Record of 1.1.0](/cran/lest/v/1.1.0.md) | Compare: [With 1.0.0](/cran/lest/compare/1.0.0...1.1.0.md), [With another package](/compare/lest.md#add), [Downloads](/downloads/compare/lest.md#add) | [Licences](/cran/lest/licences.md) | [SBOM](/cran/lest/sbom.md)

Install from CRAN: `install.packages("lest")`

Also from:

- r2u (Ubuntu binaries): `sudo apt install r-cran-lest` _Listed from recorded download activity on this channel, not from a live index, so read it as last known. Bioconductor packages are named r-bioc-<name> there._
- autoCRAN (openSUSE): `sudo zypper install R-lest` _Listed from recorded download activity on this channel, not from a live index, so read it as last known._

- CRAN checks: All OK (13 platforms)
- CRAN 30-day downloads: 317 (up 11.6% on the 30 days before, the better direction)
- Dependent packages: 0 (none suggest it)
- Test coverage: 91% (of lines run by tests)
- Advisories: None known

## About

[Method](/about/licenses.md)

Functions for vectorised conditional recoding of variables. case_when() enables you to vectorise multiple if and else statements (like 'CASE WHEN' in 'SQL'). if_else() is a stricter and more predictable version of ifelse() in 'base' that preserves attributes. These functions are forked from 'dplyr' with all package dependencies removed and behave identically to the originals.

- Maintainer: Stefan Fleck
- Licence: [MIT + file LICENSE](/licences/MIT.md)
- Latest release: 29 Nov 2019
- First release: 16 Aug 2018

- [CRAN page](https://cran.r-project.org/package=lest)
- [Source of every release](https://github.com/cran/lest)

[Compare with another package](/compare/lest.md#add)

**More details**

- Releases: 2
- Needs compilation: Yes
- LazyData: true
- RoxygenNote: 7.0.1.9000

**Subjects (1) [Method](/about/subjects.md#found)**

- [Database interfaces and SQL](/topics/subjects/database-interfaces-and-sql.md)

**Cite**

#### Package

Run in R for the authors' preferred citation:

`citation("lest")`

APA: Fleck, S., François, R., Henry, L., Müller, K., & Wickham, H. (2019). lest: Vectorised Nested if-else Statements Similar to CASE WHEN in
'SQL' (Version 1.1.0) [Computer software]. https://doi.org/10.32614/CRAN.package.lest

BibTeX:

```
@Manual{lest,
  title  = {lest: Vectorised Nested if-else Statements Similar to CASE WHEN in
'SQL'},
  author = {Fleck, Stefan and François, Romain and Henry, Lionel and Müller, Kirill and Wickham, Hadley},
  year   = {2019},
  note   = {R package version 1.1.0},
  doi    = {10.32614/CRAN.package.lest},
  url    = {https://CRAN.R-project.org/package=lest}
}
```

This package has no citation file, so `citation()` returns this entry built from `DESCRIPTION`.

#### R Observatory

For a number measured here: a download total, a coverage figure, an archival date.

APA: Balamuta, J. J. (2026). R Observatory: Metrics for lest version 1.1.0 [Data set]. HJJB, LLC. Data release v2026-10-29. https://doi.org/10.5281/zenodo.21843040

BibTeX:

```
@misc{robservatorylest,
  author    = {Balamuta, James Joseph},
  title     = {{R} {Observatory}: Metrics for {lest} version 1.1.0},
  year      = {2026},
  publisher = {HJJB, LLC},
  doi       = {10.5281/zenodo.21843040},
  url       = {https://r-observatory.thecoatlessprofessor.com/packages/lest},
  note      = {Data set. Data release v2026-10-29}
}
```

From data release v2026-10-29, which the citation names so these numbers can be found later.

## Health

[Method](/about/checks-health.md)

All 13 check platforms pass.

13 CRAN platforms: 13 OK.

Platforms now:

- r-devel-linux-x86_64-debian-clang: OK
- r-devel-linux-x86_64-debian-gcc: OK
- r-devel-linux-x86_64-fedora-clang: OK
- r-devel-linux-x86_64-fedora-gcc: OK
- r-devel-windows-x86_64: OK
- r-oldrel-macos-arm64: OK
- r-oldrel-macos-x86_64: OK
- r-oldrel-windows-x86_64: OK
- r-patched-linux-x86_64: OK
- r-release-linux-x86_64: OK
- r-release-macos-arm64: OK
- r-release-macos-x86_64: OK
- r-release-windows-x86_64: OK

#### Over time

No change since 5 Aug 2026

**As a list (4)**

| Changed | Worst status | OK | Notes | Warnings | Errors |
| --- | --- | ---: | ---: | ---: | ---: |
| 5 Aug 2026 | OK | 13 | 0 | 0 | 0 |
| 1 Aug 2026 | Note | 12 | 1 | 0 | 0 |
| 25 Apr 2026 | OK | 12 | 0 | 0 | 0 |
| 10 Mar 2026 | Note | 11 | 3 | 0 | 0 |

Since March 2026

[Check results on CRAN](https://cran.r-project.org/web/checks/check_results_lest.html)

## Downloads

[Method](/about/downloads.md)

- Downloads in the last 30 days: 328 (up 6.1% on the 30 days before, the better direction. It is the sum of 3 channels: CRAN, r2u and autoCRAN.)

CRAN alone: rank among CRAN packages, last 30 days: 12,770 of 26,553.

| Channel | Downloads in the last 30 days | In the total | Rank in that channel | Change |
| --- | ---: | --- | --- | --- |
| CRAN | 317 | yes | 12,770 of 26,553 | up 11.6% on the 30 days before, the better direction |
| r2u | 8 | yes | 7,389 of 30,526 | down 50% on the 30 days before, the worse direction |
| autoCRAN | 3 | yes | 18,475 of 29,233 | down 66.7% on the 30 days before, the worse direction |

Other windows: [Last 90 days](/cran/lest.md?win=90d#downloads), [Last 365 days](/cran/lest.md?win=365d#downloads), [All time](/cran/lest.md?win=all#downloads).

To leave channels out of the total, name them in the address, joined by dots: `?off=r2u.autocran`.

#### Over time

Downloads over time, the last 12 whole months:

| Month | CRAN | r2u | autoCRAN | Sum |
| --- | ---: | ---: | ---: | ---: |
| Oct 2025 | 310 | 30 | no figure | 340 |
| Nov 2025 | 182 | 32 | no figure | 214 |
| Dec 2025 | 181 | 25 | no figure | 206 |
| Jan 2026 | 231 | 31 | no figure | 262 |
| Feb 2026 | 190 | 37 | no figure | 227 |
| Mar 2026 | 239 | 31 | no figure | 270 |
| Apr 2026 | 236 | 48 | no figure | 284 |
| May 2026 | 237 | 43 | no figure | 280 |
| Jun 2026 | 295 | 23 | no figure | 318 |
| Jul 2026 | 210 | 21 | no figure | 231 |
| Aug 2026 | 179 | 18 | 16 | 213 |
| Sep 2026 | 288 | no figure | 9 | 297 |

First day on record: CRAN 16 Aug 2018, r2u 22 May 2022, autoCRAN 8 Jul 2026.

Every channel here counts downloads, so the channels can be stacked and summed for one period. Each channel counts in its own way and covers a different span of years, so read a sum as a rough total, and read a rise where a channel begins as that channel starting, not as growth.

Weeks start on Monday. A first or last week or month that the channel does not cover in full is left out, so every point is a whole period.

Days with no record add nothing to their week or month. For a little-used package that is usually a day with no downloads, but it can also be a gap in collection.

[Compare downloads](/downloads/compare/lest.md#add)

## Dependencies

[Method](/about/reverse-dependencies.md)

- Needs: 0
- Dependent packages: 0
- Suggested by: 0

**Optional extras (1)**

- [testthat](/cran/testthat.md)

## Code

[Method](/about/code-metrics.md)

Selected function: `replace_with`

- Kind: Internal R function
- File: R/utils.R, line 42
- Lines: 23
- Complexity: 3
- Covered by tests: 100%

Called by 2: [`case_when`](/cran/lest.md?fn=case_when&view=focus#code) (98% of lines run by tests), [`if_else`](/cran/lest.md?fn=if_else&view=focus#code) (100% of lines run by tests)

Calls 3: [`assert_length_1_or_n`](/cran/lest.md?fn=assert_length_1_or_n&view=focus#code) (100% of lines run by tests), [`assert_equal_class`](/cran/lest.md?fn=assert_equal_class&view=focus#code) (93% of lines run by tests), [`assert_equal_type`](/cran/lest.md?fn=assert_equal_type&view=focus#code) (83% of lines run by tests)

Paths: 2 steps each way.

Called by 2:

- [`case_when`](/cran/lest.md?fn=case_when&view=focus#code)
- [`if_else`](/cran/lest.md?fn=if_else&view=focus#code)

Calls 3:

- [`assert_length_1_or_n`](/cran/lest.md?fn=assert_length_1_or_n&view=focus#code), calls 1
  - [`check_length_1_or_n`](/cran/lest.md?fn=check_length_1_or_n&view=focus#code), calls 1
- [`assert_equal_class`](/cran/lest.md?fn=assert_equal_class&view=focus#code)
- [`assert_equal_type`](/cran/lest.md?fn=assert_equal_type&view=focus#code)

The open file in the files map is `R/utils.R`.

- Functions: 12
- Lines: 134
- Calls that stay inside it: 7
- Calls to other files: 0
- Calls from other files: 7, from 2

Called from: `R/case_when.R` (6 calls), `R/if_else.R` (1 call)

| Function in utils.R | Calls in other files |
| --- | --- |
| [`replace_with`](/cran/lest.md?fn=replace_with&view=focus#code) selected | nothing outside this file |
| [`assert_equal_class`](/cran/lest.md?fn=assert_equal_class&view=focus#code) | nothing outside this file |
| [`assert_equal_type`](/cran/lest.md?fn=assert_equal_type&view=focus#code) | nothing outside this file |
| [`assert_length_1_or_n`](/cran/lest.md?fn=assert_length_1_or_n&view=focus#code) | nothing outside this file |
| [`backticks`](/cran/lest.md?fn=backticks&view=focus#code) | nothing outside this file |

**More functions (7)**

| Function in utils.R | Calls in other files |
| --- | --- |
| [`bad_calls`](/cran/lest.md?fn=bad_calls&view=focus#code) | nothing outside this file |
| [`check_length_1_or_n`](/cran/lest.md?fn=check_length_1_or_n&view=focus#code) | nothing outside this file |
| [`deparse_trunc`](/cran/lest.md?fn=deparse_trunc&view=focus#code) | nothing outside this file |
| [`f_lhs`](/cran/lest.md?fn=f_lhs&view=focus#code) | nothing outside this file |
| [`f_rhs`](/cran/lest.md?fn=f_rhs&view=focus#code) | nothing outside this file |
| [`fmt_calls`](/cran/lest.md?fn=fmt_calls&view=focus#code) | nothing outside this file |
| [`inconsistent_lengths_message`](/cran/lest.md?fn=inconsistent_lengths_message&view=focus#code) | nothing outside this file |


2 files with no calls to or from another: `R/lest-package.R`, `src/init.c`.

The whole package has 75 function names in 10 files and 52 calls between them. Most calls between files: `R/case_when.R` and `R/utils.R` (6 calls), `R/exceeds_tumbling_sum.R` and `R/utils-sfmisc.R` (3 calls), `R/cumall.R` and `src/cumall.c` (2 calls), `R/exceeds_tumbling_sum.R` and `src/exceeds_tumbling_sum.c` (2 calls), `R/if_else.R` and `R/utils.R` (1 call).

Graph: the whole call graph has 53 function names that take part in a call and 52 calls between them, set out in 5 layers with callers before what they call. 22 function names have no calls and are left out. Called by the most functions: `is_scalar` (14), `assert` (6), `backticks` (2), `inconsistent_lengths_message` (2), `replace_with` (2). Calling the most functions: `case_when` (6), `exceeds_tumbling_sum` (5), `replace_with` (3), `is_scalar_integerish` (2), `equalish` (2).

Most connected functions: [`is_scalar`](/cran/lest.md?fn=is_scalar&view=focus#code) 14, [`assert`](/cran/lest.md?fn=assert&view=focus#code) 6, [`case_when`](/cran/lest.md?fn=case_when&view=focus#code) 6, [`exceeds_tumbling_sum`](/cran/lest.md?fn=exceeds_tumbling_sum&view=focus#code) 5, [`replace_with`](/cran/lest.md?fn=replace_with&view=focus#code) 5, [`is_scalar_integerish`](/cran/lest.md?fn=is_scalar_integerish&view=focus#code) 4

To select another function, add ?fn=NAME to this address.

The call graph also has an address of its own: /cran/lest/graph.md?fn=replace_with&view=focus

- Functions: 76
- Public exports: 5
- Lines of R code: 1,269
- Median complexity: 2

**Functions (76)**

| Function (sorted, low to high) | Kind | File | Lines | Complexity | Covered |
| --- | --- | --- | ---: | ---: | ---: |
| [`case_when`](/cran/lest.md?fn=case_when#code) | Public | R/case_when.R | 68 | 9 | 98% |
| [`cumall`](/cran/lest.md?fn=cumall#code) | Public | R/cumall.R | 3 | 1 | 100% |
| [`cumany`](/cran/lest.md?fn=cumany#code) | Public | R/cumall.R | 3 | 1 | 100% |
| [`exceeds_tumbling_sum`](/cran/lest.md?fn=exceeds_tumbling_sum#code) | Public | R/exceeds_tumbling_sum.R | 23 | 3 | 100% |
| [`if_else`](/cran/lest.md?fn=if_else#code) | Public | R/if_else.R | 37 | 2 | 100% |
| [`%\|\|%`](/cran/lest.md?fn=%25%7C%7C%25#code) | Internal | R/utils-sfmisc.R | 5 | 2 |  |
| [`.onUnload`](/cran/lest.md?fn=.onUnload#code) | Internal | R/lest-package.R | 3 | 1 | 0% |
| [`all_are_distinct`](/cran/lest.md?fn=all_are_distinct#code) | Internal | R/utils-sfmisc.R | 23 | 4 |  |
| [`all_are_identical`](/cran/lest.md?fn=all_are_identical#code) | Internal | R/utils-sfmisc.R | 17 | 3 |  |
| [`as_scalar`](/cran/lest.md?fn=as_scalar#code) | Internal | R/utils-sfmisc.R | 8 | 2 |  |
| [`assert`](/cran/lest.md?fn=assert#code) | Internal | R/utils-sfmisc.R | 20 | 4 |  |
| [`assert_equal_class`](/cran/lest.md?fn=assert_equal_class#code) | Internal | R/utils.R | 29 | 4 | 93% |

This page lists 1 to 12 of 76 functions. [Next](/cran/lest.md?sort=name&order=asc&fpage=2#functions)

**Size and composition**

#### Lines by kind (2,040)

| Kind | Lines | Share |
| --- | ---: | ---: |
| R code | 1,269 | 62% |
| Tests | 391 | 19% |
| Documentation | 210 | 10% |
| Compiled code | 170 | 8% |

#### Lines by language

| Language | Lines | Share |
| --- | ---: | ---: |
| R | 1,660 | 81% |
| Rd | 210 | 10% |
| C | 170 | 8% |

Languages are counted from file extensions.

- Files: 28
- R functions: 71
- Compiled functions: 5

**Complexity**

- Median: 2
- Mean: 2.03
- Highest: 11
- Median lines per function: 3

_About complexity: Cyclomatic complexity counts the independent paths through a function: 1 is a straight line, higher is harder to test. R functions only._

**Call graph figures**

- R functions: 71
- Calls: 49
- Unconnected: 23
- Groups: 3

**Growth (2 releases)**

Total lines by release: from 828 (on 16 Aug 2018) to 2,040 (on 29 Nov 2019). The lowest is 828 and the highest is 2,040.

**Release changes**

[Both releases side by side](/cran/lest/compare/1.0.0...1.1.0.md)

**1.0.0 to 1.1.0**, 16 Aug 2018 to 29 Nov 2019

- Files changed: 19
- Lines added: 1,318
- Lines deleted: 36
- Exports: 3 added, 0 removed

**Exports added (3)**

- `cumall`
- `cumany`
- `exceeds_tumbling_sum`

**Changed measures (26)**

| Measure | Subject | Before | After |
| --- | --- | ---: | ---: |
| Public exports | Structure | 2 | 5 |
| Internal functions | Structure | 12 | 64 |
| Total lines | Structure | 828 | 2,040 |
| Lines of R code | Structure | 389 | 1,269 |
| Lines of compiled code | Structure | 0 | 170 |
| Lines of tests | Structure | 299 | 391 |
| R functions | Languages | 14 | 71 |
| C functions | Languages | 0 | 5 |
| Compiled share | Languages | 0% | 8% |
| Lines of documentation | Documentation | 140 | 210 |
| Help pages with examples (share) | Documentation | 67% | 80% |
| Help pages with examples | Documentation | 2 | 4 |
| Arguments documented | Documentation | 50% | 83% |
| NEWS file | Documentation | No | Yes |
| Test cases | Testing | 20 | 23 |
| Test lines per line of code | Testing | 0.77 | 0.31 |
| Mean complexity | Complexity | 2.64 | 2.03 |
| Highest complexity | Complexity | 9 | 11 |
| Lines per function (mean) | Complexity | 17.07 | 8.58 |
| Functions (nodes) | Call graph | 14 | 71 |
| Call edges | Call graph | 14 | 49 |
| Most connections on one function | Call graph | 6 | 15 |
| Mean connections | Call graph | 2 | 1.38 |
| Functions with no connections | Call graph | 1 | 23 |
| Separate groups | Call graph | 1 | 3 |
| Calls into compiled code | Call graph | 0 | 4 |

**Most changed files (12 of 19)**

| File | Lines added | Lines deleted |
| --- | ---: | ---: |
| `R/utils-sfmisc.R` | 804 | 0 |
| `src/exceeds_tumbling_sum.c` | 93 | 0 |
| `tests/testthat/test_cumall.R` | 77 | 0 |
| `DESCRIPTION` | 39 | 15 |
| `src/cumall.c` | 53 | 0 |
| `R/exceeds_tumbling_sum.R` | 47 | 0 |
| `man/exceeds_tumbling_sum.Rd` | 37 | 0 |
| `man/lest-package.Rd` | 17 | 8 |
| `MD5` | 18 | 6 |
| `man/cumall.Rd` | 24 | 0 |
| `src/init.c` | 24 | 0 |
| `R/cumall.R` | 21 | 0 |

## Tests

[Method](/about/coverage.md)

The tests ran and coverage was measured.

- Lines run by tests: 90.6%
- Expressions run by tests: 88.7%
- Test cases: 23
- Exports named in tests: 100%

**Coverage by file (6)**

6 files measured, least covered first.

| File | Lines | Run by tests | Not run | Coverage |
|---|---:|---:|---:|---:|
| `R/lest-package.R`, 1 function | 1 | 0 | 1 | 0% |
| `R/utils.R`, 12 functions | 56 | 49 | 7 | 88% |
| `R/case_when.R`, 1 function | 46 | 45 | 1 | 98% |
| `R/cumall.R`, 2 functions | 2 | 2 | 0 | 100% |
| `R/exceeds_tumbling_sum.R`, 1 function | 11 | 11 | 0 | 100% |
| `R/if_else.R`, 1 function | 25 | 25 | 0 | 100% |

Not measured, 4 files: `R/utils-sfmisc.R`, `src/cumall.c`, `src/exceeds_tumbling_sum.c`, `src/init.c`.

**Coverage run**

- Lines counted: 141
- Lines the tests ran: 132
- Tests passed: Yes
- Measured with: covr 3.6.5 on R 4.6.1

**Test suite**

- Has tests: Yes
- Test frameworks: testthat
- Test cases: 23
- Lines of tests: 391
- Test lines per line of code: 0.31

## Documentation

[Method](/about/code-metrics.md)

- Exports documented: 100%
- Arguments documented: 83.3%
- Return value documented: 100%
- Help pages with examples: 80%
- Examples run in checks: 100%

**Other documentation**

- README: Yes, 163 words
- Release notes file: Yes
- Help pages: 5
- Lines of documentation: 210

## People

[Method](/about/author-identity.md)

- [Stefan Fleck](/people/Stefan+Fleck.md): Maintainer since 1.0.0 (2018), author. ORCID https://orcid.org/0000-0003-3344-9851
- [Romain François](/people/Romain+Fran%C3%A7ois.md): Author. ORCID https://orcid.org/0000-0002-2444-4226
- [Lionel Henry](/people/Lionel+Henry.md): Author
- [Kirill Müller](/people/Kirill+M%C3%BCller.md): Author. ORCID https://orcid.org/0000-0002-1416-3412
- [Hadley Wickham](/people/Hadley+Wickham.md): Author. ORCID https://orcid.org/0000-0003-4757-117X

## Repository

[Method](/about/repo-signals.md#figures)

No repository on record

## History

[Method](/about/archive.md)

The line runs from the first release of lest on 16 Aug 2018 to 29 Oct 2026 and marks all 2 of its releases.

| Version | Released | R |
| --- | --- | ---: |
| [1.1.0](/cran/lest/v/1.1.0.md) current | 29 Nov 2019 | 3.6.1 |
| [1.0.0](/cran/lest/v/1.0.0.md) | 16 Aug 2018 | 3.5.1 |

**Release notes (1.1.0)**

- Added `exceeds_tumbling_sum()` for checking when a partial cumulative sum

("tumbling sum"") hits a certain threshold value. This is for example useful

for filtering geographic positions by a minimum distance. Thanks to

[@klmr](https://github.com/klmr) for helping me come up with a name.

- Added plain C clones of `dplyr::cumall()` and `dplyr::cumany()`

---

R Observatory is independent of the R Project, CRAN and Bioconductor. The same page for people is at /cran/lest, and every address is listed at /llms.txt.
