I am learning time series and started with converting data into tsibble object. Data contains three variables: Date ( in the form of 2020 05) showing year and month; Brands (as A, B, C) and Sales ( as quantity)
But I get this error:
Error: A valid tsibble must have distinct rows identified by key and index. i Please use duplicates() to check the duplicated rows.
Interesting....Thanks @nirgrahamuk! Yes, I do see duplicates now. I deleted a Location variable before converting into tsibble, thinking I am only interested in Brands as key and corresponding Sales forgetting about unique combinations where location and Brands combination kept it as unique rows earlier.
So, now that I have included it back in the game, how can I specify a combination of two variables as key for tsibble. In this case, Location and Brands. The below code doesn't seem to work.
as_tsibble(key = c(Location, Brands), index = Date)
I just found 2 duplicates even with the combinations....probably that is the problem. I will update you after fixing these duplicates...hopefully it will work then.