Skip to content

Commit

Permalink
Move as.{factor,ordered}.integer64 to integer64.R given roxygen2#1665…
Browse files Browse the repository at this point in the history
… (collation order issue)
  • Loading branch information
MichaelChirico committed Oct 13, 2024
1 parent e75e249 commit f6142e3
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 64 deletions.
56 changes: 0 additions & 56 deletions R/highlevel64.R
Original file line number Diff line number Diff line change
Expand Up @@ -2276,62 +2276,6 @@ table.integer64 <- function(
cnt
}

#' @rdname as.character.integer64
#' @export
as.factor.integer64 <- function(x) {

cache_env <- cache(x)
if (is.null(cache_env$order)){
s <- clone(x)
o <- seq_along(s)
na.count <- ramsortorder(s,o)
nu <- sortnut(s)[["nunique"]]
}else if (is.null(cache_env$sort)){
o <- cache_env$order
s <- x[o]
na.count <- cache_env$na.count
nu <- cache_env$nunique
}else{
o <- cache_env$order
s <- cache_env$sort
na.count <- cache_env$na.count
nu <- cache_env$nunique
}
dimtab <- sortuni(s, nu)
dimpos <- sortorderkey(s,o,na.skip.num=na.count) - 1L
attr(dimpos, "levels") <- dimtab
oldClass(dimpos) <- "factor"
dimpos
}

#' @rdname as.character.integer64
#' @export
as.ordered.integer64 <- function(x) {

cache_env <- cache(x)
if (is.null(cache_env$order)){
s <- clone(x)
o <- seq_along(s)
na.count <- ramsortorder(s,o)
nu <- sortnut(s)[["nunique"]]
}else if (is.null(cache_env$sort)){
o <- cache_env$order
s <- x[o]
na.count <- cache_env$na.count
nu <- cache_env$nunique
}else{
o <- cache_env$order
s <- cache_env$sort
na.count <- cache_env$na.count
nu <- cache_env$nunique
}
dimtab <- sortuni(s, nu)
dimpos <- sortorderkey(s,o,na.skip.num=na.count) - 1L
attr(dimpos, "levels") <- dimtab
oldClass(dimpos) <- c("ordered", "factor")
dimpos
}

as.integer64.factor <- function(x, ...)as.integer64(unclass(x))

#' Extract Positions in redundant dimension table
Expand Down
56 changes: 56 additions & 0 deletions R/integer64.R
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,62 @@ print.bitstring <- function(x, ...) {
NextMethod(x)
}

#' @rdname as.character.integer64
#' @export
as.factor.integer64 <- function(x) {

cache_env <- cache(x)
if (is.null(cache_env$order)){
s <- clone(x)
o <- seq_along(s)
na.count <- ramsortorder(s,o)
nu <- sortnut(s)[["nunique"]]
}else if (is.null(cache_env$sort)){
o <- cache_env$order
s <- x[o]
na.count <- cache_env$na.count
nu <- cache_env$nunique
}else{
o <- cache_env$order
s <- cache_env$sort
na.count <- cache_env$na.count
nu <- cache_env$nunique
}
dimtab <- sortuni(s, nu)
dimpos <- sortorderkey(s,o,na.skip.num=na.count) - 1L
attr(dimpos, "levels") <- dimtab
oldClass(dimpos) <- "factor"
dimpos
}

#' @rdname as.character.integer64
#' @export
as.ordered.integer64 <- function(x) {

cache_env <- cache(x)
if (is.null(cache_env$order)){
s <- clone(x)
o <- seq_along(s)
na.count <- ramsortorder(s,o)
nu <- sortnut(s)[["nunique"]]
}else if (is.null(cache_env$sort)){
o <- cache_env$order
s <- x[o]
na.count <- cache_env$na.count
nu <- cache_env$nunique
}else{
o <- cache_env$order
s <- cache_env$sort
na.count <- cache_env$na.count
nu <- cache_env$nunique
}
dimtab <- sortuni(s, nu)
dimpos <- sortorderkey(s,o,na.skip.num=na.count) - 1L
attr(dimpos, "levels") <- dimtab
oldClass(dimpos) <- c("ordered", "factor")
dimpos
}

#' @rdname as.integer64.character
#' @export
as.integer64.bitstring <- function(x, ...){
Expand Down
16 changes: 8 additions & 8 deletions man/as.character.integer64.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f6142e3

Please sign in to comment.