We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Do I need to implement more methods to make subset assignment work with "list of" classes? I wonder why my vec_cast() implementation doesn't fire.
vec_cast()
library(vctrs) new_percent <- function(x = double()) { vec_assert(x, double()) new_vctr(x, class = "vctrs_percent") } vec_ptype2.vctrs_percent.vctrs_percent <- function(x, y, ...) new_percent() vec_cast.vctrs_percent.vctrs_percent <- function(x, to, ...) x pct <- new_percent(1.5:10) pct[1] <- 2
list_of
library(vctrs) new_percent <- function(x = list()) { vec_assert(x, list()) new_list_of(x, double(), class = "vctrs_percent") } vec_ptype2.vctrs_percent.vctrs_percent <- function(x, y, ...) new_percent() vec_cast.vctrs_percent.vctrs_percent <- function(x, to, ...) { message("Casting") x } pct <- new_percent(as.list(1.5:10)) pct[1] <- new_percent(list(2)) #> Error: Can't convert <list_of<double>> to <list_of<double>>.
Created on 2021-04-26 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered:
<blob>
No branches or pull requests
Do I need to implement more methods to make subset assignment work with "list of" classes? I wonder why my
vec_cast()
implementation doesn't fire.Works with atomic vector
Fails with
list_of
Created on 2021-04-26 by the reprex package (v2.0.0)
The text was updated successfully, but these errors were encountered: