vctrs - incompatible types.

## R version 4.0.5.
## latest 'tidyverse' package.
library('dplyr')
library('tibble')

df <- data.frame(x = letters[1:3],
                 y = c(52, 35, 5))

### Code adds a new row to df with the value 100 - (52 + 35 + 5).

### Code below works. In order to make it work, I had
### to 'deframe' df.
df1 <- df %>%
  add_row(x = "d",
          y = 100 - deframe(summarise(., across(where(is.numeric), sum)
          )))

### Code below used to work before installing the latest
### 'tidyverse' package.  No 'deframe' was necessary.  See error message below.
df2 <- df %>%
  add_row(x = "d",
                      y = 100 - summarise_if(., is.numeric, sum))

### Error: Can't combine `..1$y` <double> and `..2$y` <data.frame>.

# Run `rlang::last_error()` to see where the error occurred.
# > rlang::last_error()
# <error/vctrs_error_incompatible_type>
# Can't combine `..1$y` <double> and `..2$y` <data.frame>.
# Backtrace:
#   1. `%>%`(...)
# 2. tibble::add_row(...)
# 3. tibble:::rbind_at(.data, df, pos)
# 4. vctrs::vec_rbind(old, new)
# 6. vctrs::vec_default_ptype2(...)
# 7. vctrs::stop_incompatible_type(...)
# 8. vctrs:::stop_incompatible(...)
# 9. vctrs:::stop_vctrs(...)

I think your fix and the error are correct. vctrs is checking for rows that shouldn't be bound because they are of two different types, one a double, and the other a data frame. Is the issue that you think the latter is not a data frame, and thus it's an error?

If so, you might want to file an issue in vctrs.

Thanks, Mara for your prompt answer.

Yes, I think in the example I gave, the issue is that the latter shall not be a data frame. If I sum over one numeric vector, should the result be a double instead?

In fact, I sent this ticket because my code broke after installing R 4.0.5 (from R 3.6.1) and the latest Tidyverse packages.

The lines below used to work:
df2 <- df %>%
add_row(x = "d",
y = 100 - summarise_if(., is.numeric, sum))

I fixed the code (and used the new function 'across'):
df1 <- df %>%
add_row(x = "d",
y = 100 - deframe(summarise(., across(where(is.numeric), sum)
)))

Frédéric.