Using ifelse function in DS

I’ve added ifelse to my list of assign methods on both my servers but when I try:

ds.assign(toAssign = 'ifelse(D$VALUE<6, 1, 0), newobj = 'VAR1')

I get a bad request error message. I’ll note that I’ve logged in via the R environment after the function was added to the list of assign methods and that D$VALUE is class numeric. Any ideas?

Jack,

Could I confirm you have missed a ’ in your example, but not when you where testing. Which version of DataSHIELD are you using? I believe ‘<’ isn’t permitted in strings.

Stuart

1 Like

Sorry, there is a typo there; it should be

ds.assign(toAssign = 'ifelse(D$VALUE<6, 1, 0)', newobj = 'VAR1')

If, as you say, boolean operators are not permitted in strings then I guess that explains the error. I’ll just have to think of an alternative solution.

Cheers, Jack

Hi Jack,

I think the function you need is ds.Boole:

https://cran.datashield.org/web/dsBaseClient/ds.Boole.html

Tom

1 Like

Thanks Tom, that function provides what I was looking for.