To keep it simple I created small dummy dataset.
library(tidyverse)
library(lubridate)
myDF <- tibble(country = rep(c("UK", "US"), each = 3),
date = c("2020-01-01", "2020-02-01", "2020-02-01", "2020-03-01",
"2020-03-01", "2020-03-01"))
myDF <- myDF %>% mutate(date = as_date(date))
country date
<chr> <date>
1 UK 2020-01-01
2 UK 2020-02-01
3 UK 2020-02-01
4 US 2020-03-01
5 US 2020-03-01
6 US 2020-03-01
I know the unique() function can be used to find that there are 3 unique values ("2020-01-01", "2020-02-01", "2020-03-01") in the date column.
unique(myDF$date) # the unique values
length(unique(myDF$date)) # number of unique values
But how can I create a small table output which displays the frequency of each of these unique occurrences in a specific column (i.e. date) in my dataset? I am looking for something like this:
myDF$date freq
"2020-01-01" 1
"2020-02-01" 2
"2020-03-01" 3