# Case\_when equivalent in DataSHIELD

**URL:** <https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005>\
**Category:** Analyst Support\
**Created:** [19 April 2024 11:03 UTC](https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005 "2024-04-19T11:03:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aakkoc](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/aakkoc/32/200_2.png) [@aakkoc](https://datashield.discourse.group/u/aakkoc)\
**Post date:** [19 April 2024 11:03 UTC](https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005/1 "2024-04-19T11:03:43Z")

</div>

Hi!

I was wondering if there was a [case\_when](https://dplyr.tidyverse.org/reference/case_when.html) equivalent in DataSHIELD. dsSwissKnife or similar packages are also fine, if not in dsBase.

Cheers.

---

<div class="post-metadata">

**Author:** ![timmyjc](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@timmyjc](https://datashield.discourse.group/u/timmyjc)\
**Post date:** [19 April 2024 11:15 UTC](https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005/2 "2024-04-19T11:15:55Z")

</div>

Hi there,

I’m currently developing a ds.tidyverse package which will include the case\_when function. I’m hoping to have an initial release of this within a few months.

cheers

Tim

---

<div class="post-metadata">

**Author:** ![demetris.avraam](https://avatars.discourse-cdn.com/v4/letter/d/439d5e/32.png) [@demetris.avraam](https://datashield.discourse.group/u/demetris.avraam)\
**Post date:** [19 April 2024 14:08 UTC](https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005/3 "2024-04-19T14:08:47Z")

</div>

Hi Ahmet,

While waiting the development of ds.tidyverse, you can use the combination of ds.Boole and ds.make functions to apply the case\_when conditions. See for example this: [Fill in missing values of variable with values of second variable: ds.replaceNA?](https://datashield.discourse.group/t/fill-in-missing-values-of-variable-with-values-of-second-variable-ds-replacena/666) and let me know if you need any help with this.

Thanks, Demetris

---

<div class="post-metadata">

**Author:** ![timmyjc](https://avatars.discourse-cdn.com/v4/letter/t/45deac/32.png) [@timmyjc](https://datashield.discourse.group/u/timmyjc)\
**Post date:** [26 August 2024 15:24 UTC](https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005/4 "2024-08-26T15:24:40Z")

</div>

Hi Ahmed,

There are now development versions of dsTidyverse and dsTidyverseClient available, which contain the functions `ds.case_when()` and `caseWhenDS`. You can find the packages here:

> **[GitHub - molgenis/ds-tidyverse](https://github.com/molgenis/ds-tidyverse)**
>
> Contribute to molgenis/ds-tidyverse development by creating an account on GitHub.

> **[GitHub - molgenis/ds-tidyverse-client](https://github.com/molgenis/ds-tidyverse-client)**
>
> Contribute to molgenis/ds-tidyverse-client development by creating an account on GitHub.

Best, Tim

---

<div class="post-metadata">

**Author:** ![aakkoc](https://yyz2.discourse-cdn.com/free1/user_avatar/datashield.discourse.group/aakkoc/32/200_2.png) [@aakkoc](https://datashield.discourse.group/u/aakkoc)\
**Post date:** [29 August 2024 13:46 UTC](https://datashield.discourse.group/t/case-when-equivalent-in-datashield/1005/5 "2024-08-29T13:46:17Z")

</div>

This is great news!

Very glad to see you making big strides with ds-tidyverse 🙂
