tsibble
tsibble copied to clipboard
Naming Conflict in as_tsibble() Results in Unsupported Index Error
Details
When a data frame is passed to as_tsibble() with a column named index the object conversion fails.
Consider the following example, where the grouping variable is stored as "index", the time variable stored as "qtr", and the time series value named "value".
tbl2 <- tibble(
qtr = rep(yearquarter("2010 Q1") + 0:9, 3),
index = rep(c("x", "y", "z"), each = 10),
value = rnorm(30)
)
as_tsibble(tbl2, key = index, index = qtr)
Results:
Error in `validate_index()`:
! Unsupported index type: character
Eliminating naming conflicts with specials fixes the error.
tbl2_conf <- tbl2%>%
rename(grp = index)
as_tsibble(tbl2_conf , key = grp, index = qtr)