0

I am trying to count the # of unique date values across multiple visits. Here is sample data:

id    date     
1     2017-08-31
1     2017-08-31
1     2017-05-06
2     2015-09-01
2     2015-11-01
3     2010-12-02
3     2010-12-02

I want a df that shows how many unique dates there are per participant. Something like this:

id    total_visit
1       2
2       2 
3       1

I tried this code, but it's not doing what I want it to do.

library(tidyverse)
df1 <- df %>% group_by(id) %>% count(distinct(date))

Can someone please help?

D. Fowler
  • 601
  • 3
  • 7

0 Answers0