DataSHIELD implementation of dplyr::case_when.

ds.case_when(
  dynamic_dots = NULL,
  .default = NULL,
  .ptype = NULL,
  .size = NULL,
  newobj = NULL,
  datasources = NULL
)

Arguments

dynamic_dots

A sequence of two-sided formulas. The left hand side (LHS) determines which values match this case. The right hand side (RHS) provides the replacement value. The LHS inputs must evaluate to logical vectors. The RHS inputs will be coerced to their common type. All inputs will be recycled to their common size. That said, we encourage all LHS inputs to be the same size. Recycling is mainly useful for RHS inputs, where you might supply a size 1 input that will be recycled to the size of the LHS inputs. NULL inputs are ignored.

.default

The value used when all of the LHS inputs return either FALSE or NA.

.ptype

An optional prototype declaring the desired output type. If supplied, this overrides the common type of true, false, and missing.

.size

An optional size declaring the desired output size. If supplied, this overrides the size of condition.

newobj

Character specifying name for new server-side data frame.

datasources

datashield connections object.

Value

One or more new columns created on the serverside data frame specified in the newobj.

Examples

if (FALSE) {
## First log in to a DataSHIELD session with mtcars dataset loaded.

ds.case_when(
  tidy_select = list(
    mtcars$mpg < 10 ~ "low",
    mtcars$mpg >= 10 & mtcars$mpg < 20 ~ "medium",
    mtcars$mpg >= 20 ~ "high"
  ),
  newobj = "test",
  datasources = conns
)

## Refer to the package vignette for more examples.
}