Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Vectorised Nested if-else Statements Similar to SQL CASE WHEN (forked from dplyr)

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

s-fleck/lest

Repository files navigation

This package is obsolete as dplyr has saner dependencies now, and data.table also implemented a similar function

CRAN statuslifecycleTravis build status

Lest provides two functions for vectorised conditional recoding of variables.case_when() enables you to vectorise multipleif andelse statements (likeCASE WHEN in SQL).if_else() is a stricter and more predictable version ofbase::ifelse() that preserves attributes (and therefore works with Dates). Thefunctions in lest are forks of thedplyr functions ofthe same name. For more infos please refer to thedocumentation.

Why use lest?

Use this package if you like the semantics ofdplyr::case_when(), but do notwant to use dplyr because of the dependencies it comes with.If you already use dplyr in your project, you gain no advantage from lest.lest::case_when() andlest::if_else() behave exactly identical tothe dplyr equivalents, just that they do not support tidyeval syntax(like!!!).

Dependencies

lest depends only on base R, and will never add any external dependencies.

Installation

You can install lest from GitHub with:

# install.packages("devtools")devtools::install_github("s-fleck/lest")

Example

x<-1:50case_when(x%%35==0~"fizz buzz",x%%5==0~"fizz",x%%7==0~"buzz",TRUE~ as.character(x))case_when(x%%35==0~35,x%%5==0~5,x%%7==0~7,TRUE~NA)

About

Vectorised Nested if-else Statements Similar to SQL CASE WHEN (forked from dplyr)

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp