Client side COUNT with matching conditions

I’d like to count values from all the nodes using filtering expression for instance

if !column1.NA and column2==1 than 1 else 0

I cannot find the DS function to do that (aggregated sum of COUNTs from all the nodes).

Hi jch,

I don’t know whether checking for NA is possible but depending on the size of values did you consider ds.table as in ds.table(“D$column1”, “D$column2”)?

I get an output like this:

           D$column1
D$column2    0    1    NA
         0  4809  900  3849
         1  9231 1068 10002
         NA   18    6   732

In this case it would really depend on the amount of values that you have.

Hi @jch,

You can do the following steps:

  1. Use the ds.Boole to create a binary variable (let’s call it var1) with zeros if column1 is NA and ones otherwise.
  2. Use the ds.Boole to create a binary variable (let’s call it var2) with ones if column2 is equal to 1 and zeros otherwise.
  3. Use the ds.make to add var1 and var2. This gives a new variable (let’s call it var3) with 3 possible values: 0, 1 and 2
  4. Use the ds.recodeValues function to recode 2 with 1 and 1 with 0. This gives a new variable (let’s call it var4) with values 1 if the condition is correct and 0 otherwise.

Finally you can do a ds.table of var4 to see how many counts you have from all nodes.