1mychr <- function(x) { 2 structure(x, class = c("mychr", "character")) 3} 4vec_ptype2.mychr.character <- function(x, y, ...) { 5 x 6} 7vec_cast.character.mychr <- function(x, to, ...) { 8 unclass(x) 9} 10 11# Explicit method required for R CMD check: 12vctrs::s3_register("vctrs::vec_ptype2", "mychr.character", vec_ptype2.mychr.character) 13vctrs::s3_register("vctrs::vec_cast", "character.mychr", vec_cast.character.mychr) 14 15myint <- function(x) { 16 structure(x, class = c("myint", "integer")) 17} 18vec_ptype2.myint.integer <- function(x, y, ...) { 19 x 20} 21vec_cast.integer.myint <- function(x, to, ...) { 22 as.integer(unclass(x)) 23} 24 25# Explicit method required for R CMD check: 26vctrs::s3_register("vctrs::vec_ptype2", "myint.integer", vec_ptype2.myint.integer) 27vctrs::s3_register("vctrs::vec_cast", "integer.myint", vec_cast.integer.myint) 28 29mylgl <- function(x) { 30 structure(x, class = c("mylgl", "logical")) 31} 32vec_ptype2.mylgl.logical <- function(x, y, ...) { 33 x 34} 35vec_cast.logical.mylgl <- function(x, to, ...) { 36 unclass(x) 37} 38 39# Explicit method required for R CMD check: 40vctrs::s3_register("vctrs::vec_ptype2", "mylgl.logical", vec_ptype2.mylgl.logical) 41vctrs::s3_register("vctrs::vec_cast", "logical.mylgl", vec_cast.logical.mylgl) 42