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

vec_rbind(<table with numeric values>) #1190

Closed
romainfrancois opened this issue Jul 16, 2020 · 1 comment · Fixed by #1230
Closed

vec_rbind(<table with numeric values>) #1190

romainfrancois opened this issue Jul 16, 2020 · 1 comment · Fixed by #1230

Comments

@romainfrancois
Copy link
Contributor

library(vctrs)

vec_rbind(
  table(c(1, 2)) / 2, 
  table(c(1, 2)) / 2
)
#> Error: Internal error in `vec_proxy_assign_opts()`: `proxy` of type `integer` incompatible with `value` proxy of type `double`.
#> Backtrace:
#>     █
#>  1. └─vctrs::vec_rbind(table(c(1, 2))/2, table(c(1, 2))/2)
#>  2.   └─(function () ...

Created on 2020-07-16 by the reprex package (v0.3.0.9001)

This is the root cause of keyATM/keyATM#145, mentioned in tidyverse/dplyr#5376.

In keyATM/keyATM#145, I propose a solution that works around it by essentially cancelling the "tableness" of the object as I presume it's not useful. I'm not sure we would want to cover objects like:

str(table(c(1, 2)) / 2)
#>  'table' num [1:2(1d)] 0.5 0.5
#>  - attr(*, "dimnames")=List of 1
#>   ..$ : chr [1:2] "1" "2"

Created on 2020-07-16 by the reprex package (v0.3.0.9001)

but the error message was not helpful in keyATM/keyATM#145

DavisVaughan added a commit to business-science/tibbletime that referenced this issue Jul 20, 2020
@DavisVaughan
Copy link
Member

DavisVaughan commented Jul 20, 2020

I just learned that summary() creates subclassed "table"s, which can be numeric, so it definitely isn't just used for integer contingency tables by base R, even though the docs state:

table() returns a contingency table, an object of class "table", an array of integer values.
x <- summary(mtcars$mpg)

class(x)
#> [1] "summaryDefault" "table"

x
#>    Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
#>   10.40   15.43   19.20   20.09   22.80   33.90

Created on 2020-07-20 by the reprex package (v0.3.0)

It seems to be more like a wrapper type around integer / numeric arrays

lionel- added a commit to lionel-/vctrs that referenced this issue Aug 26, 2020
lionel- added a commit to lionel-/vctrs that referenced this issue Aug 27, 2020
lionel- added a commit that referenced this issue Aug 27, 2020
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.

2 participants