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

Bug s3_dispatch() for cbind() #30

Open
bendeivide opened this issue Aug 23, 2021 · 1 comment
Open

Bug s3_dispatch() for cbind() #30

bendeivide opened this issue Aug 23, 2021 · 1 comment
Labels
bug an unexpected problem or unintended behavior

Comments

@bendeivide
Copy link

The generic should dispatch in cbind.default, why didn't it happen? The output in s3_dispatch() is correct, as I would expect. But that didn't happen when I use the generic. See the code below.

Code:
cbind.default <- function(x, ...) "Test!"
x <- 1:10
sloop::s3_dispatch(cbind(structure(x, class = "numeric")))
cbind(structure(x, class = "numeric"))

Example (Output):

cbind.default <- function(x, ...) "Test!"
x <- 1:10
sloop::s3_dispatch(cbind(structure(x, class = "numeric")))
cbind.numeric
=> cbind.default

  • cbind (internal)

cbind(structure(x, class = "numeric"))
[,1]
[1,] 1
[2,] 2
[3,] 3
[4,] 4
[5,] 5
[6,] 6
[7,] 7
[8,] 8
[9,] 9
[10,] 10

@hadley hadley added the bug an unexpected problem or unintended behavior label Oct 30, 2023
@hadley
Copy link
Member

hadley commented Oct 30, 2023

cbind.default <- function(x, ...) "Test!"
x <- 1:3
sloop::s3_dispatch(cbind(structure(x, class = "numeric")))
#>    cbind.numeric
#> => cbind.default
#>  * cbind (internal)
cbind(structure(x, class = "numeric"))
#>      [,1]
#> [1,]    1
#> [2,]    2
#> [3,]    3

Created on 2023-10-30 with reprex v2.0.2

Presumably because cbind() is an internal generic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants