Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow matrices with 1 column in filter() #6082

Closed
romainfrancois opened this issue Nov 15, 2021 · 1 comment · Fixed by #6083
Closed

Allow matrices with 1 column in filter() #6082

romainfrancois opened this issue Nov 15, 2021 · 1 comment · Fixed by #6083

Comments

@romainfrancois
Copy link
Member

Since #5974 we forbid matrices. This causes some issues, e.g. with package ggcharts:

── After ─────────────────────────────────────────────────────────────────────────────────────────────────────
> checking examples ... ERROR
  Running examples in ‘ggcharts-Ex.R’ failed
  The error most likely occurred in:
  
  > ### Name: diverging_bar_chart
  > ### Title: Diverging Bar Chart
  > ### Aliases: diverging_bar_chart
  > 
  > ### ** Examples
  > 
  > if (requireNamespace("tidyr")) {
  +   library(magrittr)
  +   data(biomedicalrevenue)
  +   biomedicalrevenue %>%
  +   dplyr::filter(year > 2016) %>%
  +   tidyr::pivot_wider(
  +     values_from = revenue,
  +     names_from = year,
  +     names_prefix = "revenue_"
  +   ) %>%
  +   dplyr::mutate(diff = revenue_2018 - revenue_2017) %>%
  +   diverging_bar_chart(company, diff)
  + }
  Loading required namespace: tidyr
  > 
  > data(mtcars)
  > mtcars_z <- dplyr::transmute(
  +   .data = mtcars,
  +   model = row.names(mtcars),
  +   hpz = scale(hp)
  + )
  > 
  > diverging_bar_chart(mtcars_z, model, hpz)
  Error: Problem while computing `..1 = hpz >= 0`.
  ✖ Input `..1` must be a logical vector, not a logical[,1].
  Backtrace:
       ▆
    1. ├─ggcharts::diverging_bar_chart(mtcars_z, model, hpz)
    2. │ └─ggcharts:::diverging_chart(...)
    3. │   ├─ggplot2::geom_text(...)
    4. │   │ └─ggplot2::layer(...)
    5. │   │   └─ggplot2::fortify(data)
    6. │   ├─dplyr::filter(data, !!y >= 0)
    7. │   └─dplyr:::filter.data.frame(data, !!y >= 0)
    8. │     └─dplyr:::filter_rows(.data, ..., caller_env = caller_env())
    9. │       └─dplyr:::filter_eval(dots, mask = mask, error_call = error_call)
   10. │         ├─base::withCallingHandlers(...)
   11. │         └─mask$eval_all_filter(dots, env_filter)
   12. ├─dplyr:::dplyr_internal_error(...)
   13. │ └─rlang::abort(class = c(class, "dplyr:::internal_error"), dplyr_error_data = data)
   14. │   └─rlang:::signal_abort(cnd, .file)
   15. │     └─base::signalCondition(cnd)
   16. └─dplyr `<fn>`(`<dpl:::__>`)
  Execution halted

1 error x | 0 warnings ✓ | 0 notes ✓
@romainfrancois
Copy link
Member Author

Should we allow matrices that have one column (maybe with a warning) ?

@romainfrancois romainfrancois mentioned this issue Nov 16, 2021
17 tasks
romainfrancois added a commit that referenced this issue Nov 17, 2021
* allow matrics with 1 column in filter(), with a warning.

closes #6082

* not just yet warn in filter() for matrices with 1 column
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant