Skip to content

Commit 8a8df34

Browse files
committed
Merge branch 'vctrs-vec-restore'
2 parents b2b6384 + 85333ab commit 8a8df34

File tree

4 files changed

+19
-4
lines changed

4 files changed

+19
-4
lines changed

NAMESPACE

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ S3method(vec_cast,tbl_ts.tbl_ts)
164164
S3method(vec_cast,yearmonth.yearmonth)
165165
S3method(vec_cast,yearquarter.yearquarter)
166166
S3method(vec_cast,yearweek.yearweek)
167+
S3method(vec_proxy,tbl_ts)
167168
S3method(vec_ptype2,Date.yearmonth)
168169
S3method(vec_ptype2,Date.yearquarter)
169170
S3method(vec_ptype2,Date.yearweek)
@@ -187,6 +188,7 @@ S3method(vec_ptype2,yearweek.yearweek)
187188
S3method(vec_ptype_abbr,yearmonth)
188189
S3method(vec_ptype_abbr,yearquarter)
189190
S3method(vec_ptype_abbr,yearweek)
191+
S3method(vec_restore,tbl_ts)
190192
S3method(year,yearweek)
191193
S3method(yearmonth,"NULL")
192194
S3method(yearmonth,Date)

R/gaps.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ scan_gaps.tbl_ts <- function(.data, .full = FALSE) {
132132
sum_data <- summarise(keyed_tbl,
133133
!!idx_chr := list2(tibble(!!idx_chr := seq_generator(!!idx, int)))
134134
)
135-
} else if (.full == sym("start()")) {
135+
} else if (.full == expr("start()")) {
136136
start <- min(keyed_tbl[[idx_chr]])
137137
sum_data <- summarise(keyed_tbl,
138138
!!idx_chr := list2(tibble(
139139
!!idx_chr := seq_generator(c(start, max(!!idx)), int)
140140
))
141141
)
142-
} else if (.full == sym("end()")) {
142+
} else if (.full == expr("end()")) {
143143
end <- max(keyed_tbl[[idx_chr]])
144144
sum_data <- summarise(keyed_tbl,
145145
!!idx_chr := list2(tibble(

R/new-data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ new_data.tbl_ts <- function(.data, n = 1L, keep_all = FALSE, ...) {
5454

5555
out <- unwrap(ungroup(new_lst), .col = !!idx)
5656
if (keep_all) {
57-
out <- vec_rbind(.data[0L, ], out)
57+
out <- vec_rbind(new_data_frame(.data[0L, ]), out)
5858
} else { # reorder column names according to the data input
5959
out <- out[setdiff(names(.data), measured_vars(.data))]
6060
}
@@ -86,7 +86,7 @@ append_row <- function(.data, n = 1L, ...) {
8686
#' @export
8787
append_row.tbl_ts <- function(.data, n = 1L, ...) {
8888
new_data <- new_data(.data, n = n)
89-
out <- vec_rbind(.data, new_data)
89+
out <- vec_rbind(as_tibble(.data), as_tibble(new_data))
9090
ord <- is_ordered(.data)
9191
if (ord) ord <- NULL # re-order
9292
update_meta(out, .data, ordered = ord, interval = interval(.data))

R/vctrs-tsibble.R

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,16 @@ vec_cast.tbl_df.tbl_ts <- function(x, to, ...) {
8989
vec_cast.data.frame.tbl_ts <- function(x, to, ...) {
9090
df_cast(x, to, ...)
9191
}
92+
93+
#' @export
94+
vec_restore.tbl_ts <- function(x, to, ..., n = NULL) {
95+
# assuming `i` in order and no duplicates, minimal check for performance reason
96+
build_tsibble(x,
97+
key = key_vars(to), index = index_var(to), index2 = index2_var(to),
98+
ordered = TRUE, validate = FALSE, .drop = key_drop_default(to))
99+
}
100+
101+
#' @export
102+
vec_proxy.tbl_ts <- function(x, ...) {
103+
new_data_frame(x)
104+
}

0 commit comments

Comments
 (0)