Description Usage Arguments Examples
Adds rows with 0 values to a wide table that doesn't have consecutive dates
1 2 | addMissingDates(x, date.index = "Week", start.date = NULL,
end.date = NULL, data.frequency = 7)
|
x |
data.table. In wide format. |
date.index |
Character. The column in x that is the date variable. |
start.date |
Character in "yyyy-mm-dd" format. The first date of the required output, if NULL, function takes the min of date.index. |
end.date |
Character in "yyyy-mm-dd" format. The last date of the required output, if NULL, function takes the max of date.index. |
data.frequency |
Integer. Number of days that each row should cover, 1 = one day, 7 = one week. |
1 2 3 4 5 | x <- data.table::fread(system.file("extdata", "Newspapers.csv", package = "nladwa"))
x$Date <- as.Date(x$Date)
print(x) # missing 2015-01-03, 05, 06, 07, 08, 09
addMissingDates(x = x, date.index = "Date", data.frequency = 1) # now has them all
addMissingDates(x = x, date.index = "Date", data.frequency = 1, start.date = "2014-12-01")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.