I would like to inquire about suggestions on most efficient approach(es) to convert a dataframe (or tibble) into a tsibble.
The dataframe has dates in the first column, and all other columns represent various time series with values given at the corresponding date. I would like to efficiently create a tsibble with key = Name of each Time Series and index = each Date.
So the output would be a tsibble that would show like this:
Key Index Value
TimeSeriesOne FirstDate Value TimeSeriesOne on first date
TimeSeriesOne SecondDate Value TimeSeriesOne on second date
......................................................................
TimeSeriesOne LastDate Value TimeSeriesOne on last date
TimeSeriesTwo FirstDate Value TimeSeriesTwo on first date
......................................................................
TimeSeriesN LastDate Value TimeSeriesN on last date
Example of input data:
numRows <- 15
startDate <- lubridate::as_date('2018-06-10')
endDate <- startDate + base::months(x = numRows-1)
theDates <- base::seq.Date(
from = startDate,
to = endDate,
by = "month")
inputData <- tibble::tibble(
"Dates" = theDates,
"SeriesOne" = stats::rnorm(numRows),
"SeriesTwo" = stats::rnorm(numRows),
"SeriesThree" = stats::rnorm(numRows),
"SeriesFour" = stats::rnorm(numRows))