Skip to content

Commit

Permalink
fix vctrs for edbl_rcrd
Browse files Browse the repository at this point in the history
  • Loading branch information
emitanaka committed Oct 15, 2023
1 parent 1b2130c commit a5ec0d0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
12 changes: 12 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,24 @@ S3method(tbl_sum,edbl_table)
S3method(tbl_sum,trck_table)
S3method(type_sum,edbl_fct)
S3method(vec_cast,character.edbl_fct)
S3method(vec_cast,character.edbl_rcrd)
S3method(vec_cast,character.edbl_trt)
S3method(vec_cast,character.edbl_unit)
S3method(vec_cast,double.edbl_rcrd)
S3method(vec_cast,double.edbl_trt)
S3method(vec_cast,double.edbl_unit)
S3method(vec_cast,edbl_fct.character)
S3method(vec_cast,edbl_rcrd.character)
S3method(vec_cast,edbl_rcrd.double)
S3method(vec_cast,edbl_rcrd.integer)
S3method(vec_cast,edbl_trt.character)
S3method(vec_cast,edbl_trt.double)
S3method(vec_cast,edbl_trt.integer)
S3method(vec_cast,edbl_unit.character)
S3method(vec_cast,edbl_unit.double)
S3method(vec_cast,edbl_unit.edbl_unit)
S3method(vec_cast,edbl_unit.integer)
S3method(vec_cast,integer.edbl_rcrd)
S3method(vec_cast,integer.edbl_trt)
S3method(vec_cast,integer.edbl_unit)
S3method(vec_math,edbl_fct)
Expand Down Expand Up @@ -196,10 +202,16 @@ importFrom(vctrs,new_rcrd)
importFrom(vctrs,new_vctr)
importFrom(vctrs,vec_as_names)
importFrom(vctrs,vec_cast)
importFrom(vctrs,vec_cast.character)
importFrom(vctrs,vec_cast.double)
importFrom(vctrs,vec_cast.integer)
importFrom(vctrs,vec_data)
importFrom(vctrs,vec_is)
importFrom(vctrs,vec_math)
importFrom(vctrs,vec_ptype2)
importFrom(vctrs,vec_ptype2.character)
importFrom(vctrs,vec_ptype2.double)
importFrom(vctrs,vec_ptype2.integer)
importFrom(vctrs,vec_ptype_abbr)
importFrom(vctrs,vec_ptype_full)
importFrom(vctrs,vec_size_common)
41 changes: 26 additions & 15 deletions R/fcts.R
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ vec_math.edbl_fct <- function(.fn, .x, ...) {
get(.fn)(unclass(.x))
}

#' @importFrom vctrs vec_ptype2
#' @importFrom vctrs vec_ptype2 vec_ptype2.double vec_ptype2.integer vec_ptype2.character
#' @export
vec_ptype2.edbl_unit.character <- function(x, y, ...) y
#' @export
Expand Down Expand Up @@ -195,34 +195,45 @@ vec_ptype2.edbl_rcrd.integer <- function(x, y, ...) y
#' @export
vec_ptype2.integer.edbl_rcrd <- function(x, y, ...) x

#' @importFrom vctrs vec_cast
#' @importFrom vctrs vec_cast vec_cast.double vec_cast.integer vec_cast.character
#' @export
vec_cast.edbl_trt.double <- function(x, to, ...) to
vec_cast.edbl_trt.double <- function(x, to, ...) x
#' @export
vec_cast.double.edbl_trt <- function(x, to, ...) x
vec_cast.double.edbl_trt <- function(x, to, ...) as.numeric(unclass(x))
#' @export
vec_cast.edbl_trt.integer <- function(x, to, ...) to
vec_cast.edbl_trt.integer <- function(x, to, ...) x
#' @export
vec_cast.integer.edbl_trt <- function(x, to, ...) x
vec_cast.integer.edbl_trt <- function(x, to, ...) as.integer(unclass(x))
#' @export
vec_cast.edbl_trt.character <- function(x, to, ...) to
vec_cast.edbl_trt.character <- function(x, to, ...) x
#' @export
vec_cast.character.edbl_trt <- function(x, to, ...) x
vec_cast.character.edbl_trt <- function(x, to, ...) as.character(unclass(x))

#' @export
vec_cast.edbl_unit.double <- function(x, to, ...) to
vec_cast.edbl_unit.double <- function(x, to, ...) x
#' @export
vec_cast.double.edbl_unit <- function(x, to, ...) x
vec_cast.double.edbl_unit <- function(x, to, ...) as.numeric(unclass(x))
#' @export
vec_cast.edbl_unit.integer <- function(x, to, ...) to
vec_cast.edbl_unit.integer <- function(x, to, ...) x
#' @export
vec_cast.integer.edbl_unit <- function(x, to, ...) x
vec_cast.integer.edbl_unit <- function(x, to, ...) as.integer(unclass(x))
#' @export
vec_cast.edbl_unit.character <- function(x, to, ...) to
vec_cast.edbl_unit.character <- function(x, to, ...) x
#' @export
vec_cast.character.edbl_unit <- function(x, to, ...) x

vec_cast.character.edbl_unit <- function(x, to, ...) as.character(unclass(x))

#' @export
vec_cast.edbl_rcrd.double <- function(x, to, ...) x
#' @export
vec_cast.double.edbl_rcrd <- function(x, to, ...) as.numeric(unclass(x))
#' @export
vec_cast.edbl_rcrd.integer <- function(x, to, ...) x
#' @export
vec_cast.integer.edbl_rcrd <- function(x, to, ...) as.integer(unclass(x))
#' @export
vec_cast.edbl_rcrd.character <- function(x, to, ...) x
#' @export
vec_cast.character.edbl_rcrd <- function(x, to, ...) as.character(unclass(x))

# ADDME add_units(exist = TRUE), reset_units(exist = FALSE)

0 comments on commit a5ec0d0

Please sign in to comment.