Skip to content

vec_rbind(<table with numeric values>) #1190

Closed

Description

@romainfrancois
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

Activity

  1. added a commit that references this issue on Jul 20, 2020
  2. DavisVaughan commented on Jul 20, 2020

    @DavisVaughan
    Member

    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

  3. added 2 commits that reference this issue on Aug 26, 2020
    3869db6
    265db23
  4. added a commit that references this issue on Aug 27, 2020
    3a753aa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions