RStudio dataframe preview after piping shows old variables

After updating RStudio I found out about the new data-frame-preview in a pipeline - however, I am confused as to why previously removed columns are still shown.

Here is a screenshot of what I am talking about as well as the failing reprex:

dat <- mtcars

dat |> dplyr::mutate(Mpg = mpg, 
              mpg = NULL) |> dplyr::select(mpg)
#> Error in `dplyr::select()`:
#> ! Can't subset columns that don't exist.
#> ✖ Column `mpg` doesn't exist.

#> Backtrace:
#>      ▆
#>   1. ├─dplyr::select(dplyr::mutate(dat, Mpg = mpg, mpg = NULL), mpg)
#>   2. ├─dplyr:::select.data.frame(dplyr::mutate(dat, Mpg = mpg, mpg = NULL), mpg)
#>   3. │ └─tidyselect::eval_select(expr(c(...)), data = .data, error_call = error_call)
#>   4. │   └─tidyselect:::eval_select_impl(...)
#>   5. │     ├─tidyselect:::with_subscript_errors(...)
#>   6. │     │ └─rlang::try_fetch(...)
#>   7. │     │   └─base::withCallingHandlers(...)
#>   8. │     └─tidyselect:::vars_select_eval(...)
#>   9. │       └─tidyselect:::walk_data_tree(expr, data_mask, context_mask)
#>  10. │         └─tidyselect:::eval_c(expr, data_mask, context_mask)
#>  11. │           └─tidyselect:::reduce_sels(node, data_mask, context_mask, init = init)
#>  12. │             └─tidyselect:::walk_data_tree(new, data_mask, context_mask)
#>  13. │               └─tidyselect:::as_indices_sel_impl(...)
#>  14. │                 └─tidyselect:::as_indices_impl(...)
#>  15. │                   └─tidyselect:::chr_as_locations(x, vars, call = call, arg = arg)
#>  16. │                     └─vctrs::vec_as_location(...)
#>  17. └─vctrs (local) `<fn>`()
#>  18.   └─vctrs:::stop_subscript_oob(...)
#>  19.     └─vctrs:::stop_subscript(...)
#>  20.       └─rlang::abort(...)
─ Session info ────────────────────────────────────────────────────────────────────────────────────────────────────
 setting  value
 version  R version 4.2.3 (2023-03-15)
 os       macOS Ventura 13.2.1
 system   aarch64, darwin20
 ui       RStudio
 language (EN)
 collate  en_US.UTF-8
 ctype    en_US.UTF-8
 tz       Europe/Zurich
 date     2023-03-24
 rstudio  2023.03.0+386 Cherry Blossom (desktop)
 pandoc   3.1.1 @ /opt/homebrew/bin/ (via rmarkdown)


dplyr 1.1.0

Is this intended? as a user I was a little surprised to still see the variable, given names() would not show it anymore - but anyway, thanks for this nice surprise after updating :slight_smile:

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.