Skip to content

Commit

Permalink
Avoid grouping keys for tsibbles without keys
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchelloharawild committed Sep 16, 2019
1 parent 6293474 commit 00d67d9
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions R/features.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,12 @@ features_impl <- function(.tbl, .var, features, ...){

# Compute response
key_dt <- key_data(.tbl)
.resp <- unclass(
dplyr::transmute(
dplyr::new_grouped_df(as_tibble(.tbl), key_dt),
!!!.var
)
)

if(NCOL(key_dt) > 1){
.resp <- .resp[-seq_len(NCOL(key_dt) - 1)]
.tbl <- as_tibble(.tbl)
if(NROW(key_dt) > 1){
.tbl <- dplyr::new_grouped_df(.tbl, key_dt)
}

.resp <- unclass(dplyr::transmute(.tbl, !!!.var))
.resp <- .resp[seq_along(.var) + NCOL(key_dt) - 1]
names(.resp) <- names(.var)

# Compute features
Expand Down

0 comments on commit 00d67d9

Please sign in to comment.