tidyverts / tsibble

Tidy Temporal Data Frames and Tools
https://tsibble.tidyverts.org
GNU General Public License v3.0
528 stars 50 forks source link

Automatically 'arrange' after a join with tsibble #247

Closed pgg1309 closed 3 years ago

pgg1309 commented 3 years ago

When joining two tsibbles, the outcome may be in the 'wrong order'. Since tsibble is used for time series, it would be nice if the outcome of any join could be automatically sorted (arrange) by the index, or key/index pair.

x <- rnorm(100)
x <- cumsum(x)
dt <- tsibble::yearquarter("1950 Q1")
dt <- seq(dt, by = 1, along.with = x)
A <- as_tsibble(tibble(index = dt, x = x))

y <- cumsum(rnorm(30))
B <- as_tsibble(tibble(index = dt[25:54], y = y)) 

Z <- full_join(B, A)
head(Z)
head(arrange(Z, index))
earowang commented 3 years ago

Thanks. Yes, it should re-arrange the joined outcome.