Skip to content

Commit 036025b

Browse files
committed
minor tweaks
1 parent ab1768d commit 036025b

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

R/as-tsibble.R

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -266,8 +266,7 @@ build_tsibble <- function(x, key = NULL, key_data = NULL, index, index2 = index,
266266
assert_key_data(key_data)
267267
key <- head(names(key_data), -1L)
268268
}
269-
key_pos <- eval_select(enquo(key), data = x)
270-
key_vars <- syms(names(x)[key_pos])
269+
key_vars <- names(eval_select(enquo(key), data = x))
271270

272271
tbl <- as_tibble(x)
273272
# extract or pass the index var
@@ -288,11 +287,11 @@ build_tsibble <- function(x, key = NULL, key_data = NULL, index, index2 = index,
288287
}
289288
# arrange index from past to future for each key value
290289
if (vec_size(tbl) == 0 || is_null(ordered)) { # first time to create a tsibble
291-
tbl <- arrange(tbl, !!!key_vars, !!sym(index))
290+
tbl <- arrange(tbl, !!!syms(key_vars), !!sym(index))
292291
ordered <- TRUE
293292
}
294293
if (!is_key_data) {
295-
key_data <- group_data(group_by(tbl, !!!key_vars, .drop = .drop))
294+
key_data <- group_data(grouped_df(tbl, vars = key_vars, drop = .drop))
296295
}
297296
if (!ordered) { # if false, double check
298297
ordered <- validate_index_order(tbl, key_data, index)
@@ -335,7 +334,7 @@ build_tsibble_meta <- function(x, key_data = NULL, index, index2,
335334
# convert grouped_df to tsibble:
336335
# the `groups` arg must be supplied, otherwise returns a `tbl_ts` not grouped
337336
if (idx_lgl) {
338-
x <- group_by(x, !!sym(index2), .add = TRUE)
337+
x <- grouped_df(x, vars = union(group_vars(x), index2))
339338
}
340339
grp_data <- x %@% "groups"
341340
x <- new_tibble(x,

R/tidyr-verbs.R

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ unnest_check_tsibble <- function(data, key, index) {
139139
#' Unnest a data frame consisting of tsibbles to a tsibble
140140
#'
141141
#' @description
142-
#' \lifecycle{questioning}
142+
#' \lifecycle{deprecated}
143143
#'
144144
#' @param data A data frame contains homogenous tsibbles in the list-columns.
145145
#' @param cols Names of columns to unnest.
146146
#' @inheritParams as_tsibble
147147
#' @keywords internal
148148
#' @export
149149
unnest_tsibble <- function(data, cols, key = NULL, validate = TRUE) {
150+
# seems not working anymore
150151
if (!is_installed("tidyr") && utils::packageVersion("tidyr") >= "0.9.0") {
151152
abort("Package 'tidyr' (>= v1.0.0) required for `unnest_tsibble()`.")
152153
}
@@ -177,7 +178,7 @@ unnest_tsibble <- function(data, cols, key = NULL, validate = TRUE) {
177178
idx <- index(tsbl)
178179
}
179180

180-
key <- eval_select(enquo(key), data = unnested_data)
181+
key <- names(eval_select(enquo(key), data = unnested_data))
181182
idx_chr <- as_string(idx)
182183
class(unnested_data[[idx_chr]]) <- class(tsbl[[idx_chr]])
183184
build_tsibble(

man/unnest_tsibble.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)