0

Imagine I have measurements of 5 participants, performed on different days. The number of measurements differs between the participants. I would like to know at how many days measurements were performed for every participant

Let's say I have the following data frame (see image):

view(df)

Id  Date
1   1-2-2019
1   2-2-2019
2   5-2-2019
2   5-2-2019
3   8-2-2019
4   7-2-2019
5   9-2-2019
5   1-3-2019
5   11-4-2019

I am looking for the following result:

Id  Days
1   2
2   1
3   1
4   1
5   3

I have tried something like length(unique(df$date), by="Id")

Ronak Shah
  • 377,200
  • 20
  • 156
  • 213
Daan
  • 1

0 Answers0