I am trying to create a data frame which contains a) a time span of 51 days (time of the Corona Lockdown) and b) calculated frequencies of Tweets in this time span. The Problem is that not every day there had been tweeted, so there are dates missing in the frequency table. But in order to continue and calculate some correlations I would need a data frame which has a values/missing value for every single day of the time span. How can I achieve this? Is there any other way to calculate the frequencies? Or any way to bind the data together?
LockdownDays <- seq.Date(from = as.Date('2020-03-19'), to = as.Date('2020-05-08'), by = 'days') ##this is the date vector that contains all the dates I need values for
frequencyD <- table (ThemaD$date) ##This is the calculated frequencies from the Tweets dataset
As I said, the problem is that:
- They are of different length
- The frequency value has to match the right date in the LockdownDays vector.
So in the End I want a dataframe with the Dates on the x axis, the frequencies on y. If there is no frequency for the day I still want there to be a date in the dataframe, best would be with 0 or NA for the y value.
df <- c("2020-01-02", "2020-01-03", "2020-01-03", "2020-01-05")
freq <- table (df)
dates <- seq.Date(from = as.Date('2020-01-01'), to = as.Date('2020-01-08'), by = 'days')
print (dates)
cbind (freq, df)