I have data from videos and I am trying to make a new table which summarizes the information on number of unique users so far in the video. The first table is what I have and the second table is what I am looking for using R. I tried group by Video and Minute but that gives me unique users for that minute only.
| User | Video | Minute |
|---|---|---|
| a | V1 | 1 |
| b | V1 | 1 |
| b | V1 | 1 |
| c | V1 | 1 |
| d | V1 | 2 |
| c | V1 | 2 |
| e | V1 | 2 |
| a | V2 | 1 |
| b | V2 | 2 |
| c | V2 | 2 |
| Video | Minute | Unique Users |
|---|---|---|
| V1 | 1 | 3 |
| V1 | 2 | 5 |
| V2 | 1 | 1 |
| V2 | 2 | 3 |
I think what you're looking for is a cumulative count of distinct users, so in
Minute=2, you want to count all the users inMinute1 and 2.dplyr
base R
This is a little harder since it doesn't do
transformin a grouped sense, so we need to nest it a bit ...An alternative approach would be to
ReducetheUserlist-column to unique-ify and cumulatively-combine them, then uselengths:I don't know that it adds much value, over to you.
Data