Skip to content

Commit

Permalink
Merge pull request #64 from r-lib/rm-as-factor-i64
Browse files Browse the repository at this point in the history
Remove unused, unexported as.{factor,ordered}.integer64
  • Loading branch information
MichaelChirico authored Oct 13, 2024
2 parents c35cb5d + b91f614 commit a014e88
Show file tree
Hide file tree
Showing 9 changed files with 6 additions and 88 deletions.
2 changes: 1 addition & 1 deletion R/cache.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
#! \code{\link[bit]{still.identical}} for testing whether to symbols point to the same RAM. \cr
#! Functions that get and set small cache-content automatically when a cache is present: \code{\link[bit:Metadata]{na.count}}, \code{\link[bit:Metadata]{nvalid}}, \code{\link[bit:Metadata]{is.sorted}}, \code{\link[bit:Metadata]{nunique}} and \code{\link[bit:Metadata]{nties}} \cr
#! Setting big caches with a relevant memory footprint requires a conscious decision of the user: \code{\link{hashcache}}, \code{\link{sortcache}}, \code{\link{ordercache}} and \code{\link{sortordercache}} \cr
#! Functions that use big caches: \code{\link{match.integer64}}, \code{\link{\%in\%.integer64}}, \code{\link{duplicated.integer64}}, \code{\link{unique.integer64}}, \code{\link{unipos}}, \code{\link{table.integer64}}, \code{\link{as.factor.integer64}}, \code{\link{as.ordered.integer64}}, \code{\link{keypos}}, \code{\link{tiepos}}, \code{\link{rank.integer64}}, \code{\link{prank}}, \code{\link{qtile}}, \code{\link{quantile.integer64}}, \code{\link{median.integer64}} and \code{\link{summary.integer64}} \cr
#! Functions that use big caches: \code{\link{match.integer64}}, \code{\link{\%in\%.integer64}}, \code{\link{duplicated.integer64}}, \code{\link{unique.integer64}}, \code{\link{unipos}}, \code{\link{table.integer64}}, \code{\link{keypos}}, \code{\link{tiepos}}, \code{\link{rank.integer64}}, \code{\link{prank}}, \code{\link{qtile}}, \code{\link{quantile.integer64}}, \code{\link{median.integer64}} and \code{\link{summary.integer64}} \cr
#! }
#! \examples{
#! x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
Expand Down
12 changes: 1 addition & 11 deletions R/highlevel64.R
Original file line number Diff line number Diff line change
Expand Up @@ -2210,11 +2210,6 @@ unipos.integer64 <- function(x
#! \note{
#! Note that by using \code{\link{as.integer64.factor}} we can also input
#! factors into \code{table.integer64} -- only the \code{\link{levels}} get lost.
#! \cr
#! Note that because of the existence of \code{\link{as.factor.integer64}}
#! the standard \code{\link{table}} function -- within its limits -- can also be used
#! for \code{\link{integer64}}, and especially for combining \code{\link{integer64}} input
#! with other data types.
#! }
#! \seealso{
#! \code{\link{table}} for more info on the standard version coping with Base R's data types, \code{\link{tabulate}} which can faster tabulate \code{\link{integer}s} with a limited range \code{[1L .. nL not too big]}, \code{\link{unique.integer64}} for the unique values without counting them and \code{\link{unipos.integer64}} for the positions of the unique values.
Expand All @@ -2232,19 +2227,14 @@ unipos.integer64 <- function(x
#! message("via as.integer64.factor we can use 'table.integer64' also for factors")
#! table.integer64(x, as.integer64(as.factor(z)))
#!
#! message("via as.factor.integer64 we can also use 'table' for integer64")
#! table(x)
#! table(x, exclude=NULL)
#! table(x, z, exclude=NULL)
#!
#! \dontshow{
#! stopifnot(identical(table.integer64(as.integer64(c(1,1,2))), table(c(1,1,2))))
#! stopifnot(identical(table.integer64(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4))))
#! message("the following works with three warnings due to coercion")
#! stopifnot(identical(table.integer64(c(1,1,2)), table(c(1,1,2))))
#! stopifnot(identical(table.integer64(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4))))
#! stopifnot(identical(table.integer64(c(1,1,2),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4))))
#! message("the following works because of as.factor.integer64")
#! message("the following works because of ?")
#! stopifnot(identical(table(as.integer64(c(1,1,2))), table(c(1,1,2))))
#! stopifnot(identical(table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4))))
#! stopifnot(identical(table(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4))))
Expand Down
56 changes: 0 additions & 56 deletions R/integer64.R
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,6 @@
#! \code{\link{unipos.integer64}} \tab \code{\link{unipos}} \tab positions corresponding to unique values (h/s/o/so) \cr
#! \code{\link{tiepos.integer64}} \tab \code{\link{tiepos}} \tab positions of values that are tied (//o/so) \cr
#! \code{\link{keypos.integer64}} \tab \code{\link{keypos}} \tab position of current value in sorted list of unique values (//o/so) \cr
#! \code{\link{as.factor.integer64}} \tab \code{\link{as.factor}} \tab convert to (unordered) factor with sorted levels of previous values (//o/so) \cr
#! \code{\link{as.ordered.integer64}} \tab \code{\link{as.ordered}} \tab convert to ordered factor with sorted levels of previous values (//o/so) \cr
#! \code{\link{table.integer64}} \tab \code{\link{table}} \tab unique values and their frequencies (h/s/o/so) \cr
#! \code{\link{sort.integer64}} \tab \code{\link{sort}} \tab sorted vector (/s/o/so) \cr
#! \code{\link{order.integer64}} \tab \code{\link{order}} \tab positions of elements that would create sorted vector (//o/so) \cr
Expand Down Expand Up @@ -954,8 +952,6 @@
#! \alias{as.bitstring}
#! \alias{print.bitstring}
#! \alias{as.bitstring.integer64}
#! \alias{as.factor.integer64}
#! \alias{as.ordered.integer64}
#! \alias{as.list.integer64}
#! \title{
#! Coerce from integer64
Expand Down Expand Up @@ -2069,58 +2065,6 @@ print.bitstring <- function(x, ...){
NextMethod(x)
}

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
}

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.bitstring <- function(x, ...){
ret <- .Call(C_as_integer64_bitstring, x, double(length(x)))
oldClass(ret) <- "integer64"
Expand Down
2 changes: 1 addition & 1 deletion R/sortuse64.R
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@
#! \item{nomatch}{ the value to be returned if an element is not found in the hashmap }
#! \item{keep.order}{ determines order of results and speed: \code{FALSE} (the default) is faster and returns in sorted order, \code{TRUE} returns in the order of first appearance in the original data, but this requires extra work }
#! \item{probs}{ vector of probabilities in [0..1] for which we seek quantiles }
#! \item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA}, the latter needed for \code{\link{as.factor.integer64}} }
#! \item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA} }
#! \item{na.count}{ the number of \code{NA}s, needed for this low-level function algorithm }
#! \item{method}{ see details }
#! \item{\dots}{ further arguments, passed from generics, ignored in methods }
Expand Down
4 changes: 0 additions & 4 deletions man/as.character.integer64.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
\alias{as.bitstring}
\alias{print.bitstring}
\alias{as.bitstring.integer64}
\alias{as.factor.integer64}
\alias{as.ordered.integer64}
\alias{as.list.integer64}
\title{
Coerce from integer64
Expand All @@ -26,8 +24,6 @@
\method{as.double}{integer64}(x, keep.names = FALSE, \dots)
\method{as.integer}{integer64}(x, \dots)
\method{as.logical}{integer64}(x, \dots)
\method{as.factor}{integer64}(x)
\method{as.ordered}{integer64}(x)
\method{as.list}{integer64}(x, \dots)
}
\arguments{
Expand Down
2 changes: 0 additions & 2 deletions man/bit64-package.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,6 @@ is not worth it with 32x at duplicated RAM consumption).
\code{\link{unipos.integer64}} \tab \code{\link{unipos}} \tab positions corresponding to unique values (h/s/o/so) \cr
\code{\link{tiepos.integer64}} \tab \code{\link{tiepos}} \tab positions of values that are tied (//o/so) \cr
\code{\link{keypos.integer64}} \tab \code{\link{keypos}} \tab position of current value in sorted list of unique values (//o/so) \cr
\code{\link{as.factor.integer64}} \tab \code{\link{as.factor}} \tab convert to (unordered) factor with sorted levels of previous values (//o/so) \cr
\code{\link{as.ordered.integer64}} \tab \code{\link{as.ordered}} \tab convert to ordered factor with sorted levels of previous values (//o/so) \cr
\code{\link{table.integer64}} \tab \code{\link{table}} \tab unique values and their frequencies (h/s/o/so) \cr
\code{\link{sort.integer64}} \tab \code{\link{sort}} \tab sorted vector (/s/o/so) \cr
\code{\link{order.integer64}} \tab \code{\link{order}} \tab positions of elements that would create sorted vector (//o/so) \cr
Expand Down
2 changes: 1 addition & 1 deletion man/cache.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Jens Oehlschlägel <[email protected]>
\code{\link[bit]{still.identical}} for testing whether to symbols point to the same RAM. \cr
Functions that get and set small cache-content automatically when a cache is present: \code{\link[bit:Metadata]{na.count}}, \code{\link[bit:Metadata]{nvalid}}, \code{\link[bit:Metadata]{is.sorted}}, \code{\link[bit:Metadata]{nunique}} and \code{\link[bit:Metadata]{nties}} \cr
Setting big caches with a relevant memory footprint requires a conscious decision of the user: \code{\link{hashcache}}, \code{\link{sortcache}}, \code{\link{ordercache}} and \code{\link{sortordercache}} \cr
Functions that use big caches: \code{\link{match.integer64}}, \code{\link{\%in\%.integer64}}, \code{\link{duplicated.integer64}}, \code{\link{unique.integer64}}, \code{\link{unipos}}, \code{\link{table.integer64}}, \code{\link{as.factor.integer64}}, \code{\link{as.ordered.integer64}}, \code{\link{keypos}}, \code{\link{tiepos}}, \code{\link{rank.integer64}}, \code{\link{prank}}, \code{\link{qtile}}, \code{\link{quantile.integer64}}, \code{\link{median.integer64}} and \code{\link{summary.integer64}} \cr
Functions that use big caches: \code{\link{match.integer64}}, \code{\link{\%in\%.integer64}}, \code{\link{duplicated.integer64}}, \code{\link{unique.integer64}}, \code{\link{unipos}}, \code{\link{table.integer64}}, \code{\link{keypos}}, \code{\link{tiepos}}, \code{\link{rank.integer64}}, \code{\link{prank}}, \code{\link{qtile}}, \code{\link{quantile.integer64}}, \code{\link{median.integer64}} and \code{\link{summary.integer64}} \cr
}
\examples{
x <- as.integer64(sample(c(rep(NA, 9), 1:9), 32, TRUE))
Expand Down
2 changes: 1 addition & 1 deletion man/sortnut.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ sortorderrnk(sorted, order, na.count, \dots)
\item{nomatch}{ the value to be returned if an element is not found in the hashmap }
\item{keep.order}{ determines order of results and speed: \code{FALSE} (the default) is faster and returns in sorted order, \code{TRUE} returns in the order of first appearance in the original data, but this requires extra work }
\item{probs}{ vector of probabilities in [0..1] for which we seek quantiles }
\item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA}, the latter needed for \code{\link{as.factor.integer64}} }
\item{na.skip.num}{ 0 or the number of \code{NA}s. With 0, \code{NA}s are coded with 1L, with the number of \code{NA}s, these are coded with \code{NA} }
\item{na.count}{ the number of \code{NA}s, needed for this low-level function algorithm }
\item{method}{ see details }
\item{\dots}{ further arguments, passed from generics, ignored in methods }
Expand Down
12 changes: 1 addition & 11 deletions man/table.integer64.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ and \code{\link{ordertab}} (memory saving ordering).
\note{
Note that by using \code{\link{as.integer64.factor}} we can also input
factors into \code{table.integer64} -- only the \code{\link{levels}} get lost.
\cr
Note that because of the existence of \code{\link{as.factor.integer64}}
the standard \code{\link{table}} function -- within its limits -- can also be used
for \code{\link{integer64}}, and especially for combining \code{\link{integer64}} input
with other data types.
}
\seealso{
\code{\link{table}} for more info on the standard version coping with Base R's data types, \code{\link{tabulate}} which can faster tabulate \code{\link{integer}s} with a limited range \code{[1L .. nL not too big]}, \code{\link{unique.integer64}} for the unique values without counting them and \code{\link{unipos.integer64}} for the positions of the unique values.
Expand All @@ -97,19 +92,14 @@ table.integer64(x, y, return="data.frame")
message("via as.integer64.factor we can use 'table.integer64' also for factors")
table.integer64(x, as.integer64(as.factor(z)))

message("via as.factor.integer64 we can also use 'table' for integer64")
table(x)
table(x, exclude=NULL)
table(x, z, exclude=NULL)

\dontshow{
stopifnot(identical(table.integer64(as.integer64(c(1,1,2))), table(c(1,1,2))))
stopifnot(identical(table.integer64(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4))))
message("the following works with three warnings due to coercion")
stopifnot(identical(table.integer64(c(1,1,2)), table(c(1,1,2))))
stopifnot(identical(table.integer64(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4))))
stopifnot(identical(table.integer64(c(1,1,2),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4))))
message("the following works because of as.factor.integer64")
message("the following works because of ?")
stopifnot(identical(table(as.integer64(c(1,1,2))), table(c(1,1,2))))
stopifnot(identical(table(as.integer64(c(1,1,2)),as.integer64(c(3,4,4))), table(c(1,1,2),c(3,4,4))))
stopifnot(identical(table(as.integer64(c(1,1,2)),c(3,4,4)), table(c(1,1,2),c(3,4,4))))
Expand Down

0 comments on commit a014e88

Please sign in to comment.