prepare_data | R Documentation |
This function prepares the input data by filtering based on a specified date range, removing the date column, and handling missing values. It also generates time-related columns and returns the processed data.
prepare_data(
dat,
date_column_index = 1,
start_date = "19990101",
end_date = "20231231"
)
dat |
A data frame or matrix where the first column is the date and the remaining columns are the data. |
date_column_index |
The index of the date column in the input data. Default is 1. |
start_date |
A character string specifying the start date for filtering the data in 'YYYYMMDD' format. Default is '19990101'. |
end_date |
A character string specifying the end date for filtering the data in 'YYYYMMDD' format. Default is '20231231'. |
A list containing the following components:
A matrix of the filtered data with missing values handled.
A vector of integers representing the number of months from the first date in the data.
A vector of the number of entries per month.
A vector of Date objects representing the filtered dates.
data <- data.frame(Date = c("19990101", "19990115", "19990201", "19990301", "19990315", "19990401"),
Var1 = c(1, 2, -99.99, 4, 5, -99.99),
Var2 = c(3, -99.99, 6, 7, 8, 9),
Var3 = c(10, 11, 12, 13, -99.99, 15))
result <- prepare_data(data, date_column_index = 1, start_date = '19990101', end_date = '19990430')
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.