Skip to content

Make augment() return tibbles to match predict() #468

Closed
@EmilHvitfeldt

Description

@EmilHvitfeldt

Currently the augment() function matched the input class. It would be nice if it returned tibbles to match predict()

library(parsnip)

lm_spec <- linear_reg() %>%
  set_engine("lm")

lm_fit <- lm_spec %>% fit(mpg ~ ., data = mtcars)

class(mtcars)
#> [1] "data.frame"

predict(lm_fit, new_data = mtcars) %>% class()
#> [1] "tbl_df"     "tbl"        "data.frame"

augment(lm_fit, new_data = mtcars) %>% class()
#> [1] "data.frame"

augment(lm_fit, new_data = tibble::as_tibble(mtcars)) %>% class()
#> [1] "tbl_df"     "tbl"        "data.frame"

Created on 2021-04-09 by the reprex package (v1.0.0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurea feature request or enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions