Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 208188

How to group_by date to show counts of zero and non zero entries?

$
0
0

I have the following sample data. I am trying to group them in the the various dates and I need new columns to tell me how many zero entries and how many non-zero entries.

gantry_date gantry_duration
10/2/2018   126.809
10/2/2018   0
10/2/2018   38.505
10/2/2018   0
10/2/2018   63.888
10/2/2018   81.362
10/2/2018   45.055
10/1/2018   111.648
10/1/2018   0
10/1/2018   119.291
10/1/2018   0
10/1/2018   37.565
10/1/2018   33.794
10/1/2018   0
10/1/2018   0
10/1/2018   0

desired output is

         Zero   non-zero
10/1/2018   5   4
10/2/2019   2   5

I tried the following codes with different permutation of XXXX. Tried summarize, count, sum and a combination of summarize and sum or count.

data <- gantry1 %>% group_by(gantry_date) %>% XXXXX

could not get the desired output.


Viewing all articles
Browse latest Browse all 208188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>