Commit 86444b11 authored by Andreas Tille's avatar Andreas Tille

Update upstream source from tag 'upstream/0.53.1'

Update to upstream version '0.53.1'
with Debian dir 26bf4c7772e48fc193e43b723e6fb8e02888cd64
parents 27a55efd 0a4cd21a
Package: matrixStats
Version: 0.52.2
Version: 0.53.1
Depends: R (>= 2.12.0)
Suggests: base64enc, ggplot2, knitr, microbenchmark, R.devices, R.rsp
VignetteBuilder: R.rsp
Date: 2017-04-13
Date: 2018-02-10
Title: Functions that Apply to Rows and Columns of Matrices (and to
Vectors)
Authors@R: c(
......@@ -14,8 +14,16 @@ Authors@R: c(
person("Ola", "Hossjer", role="ctb"),
person("Harris", "Jaffee", role="ctb"),
person("Dongcan", "Jiang", role="ctb"),
person("Peter", "Langfelder", role="ctb"))
Author: Henrik Bengtsson [aut, cre, cph], Hector Corrada Bravo [ctb], Robert Gentleman [ctb], Ola Hossjer [ctb], Harris Jaffee [ctb], Dongcan Jiang [ctb], Peter Langfelder [ctb]
person("Peter", "Langfelder", role="ctb"),
person("Peter", "Hickey", role="ctb"))
Author: Henrik Bengtsson [aut, cre, cph],
Hector Corrada Bravo [ctb],
Robert Gentleman [ctb],
Ola Hossjer [ctb],
Harris Jaffee [ctb],
Dongcan Jiang [ctb],
Peter Langfelder [ctb],
Peter Hickey [ctb]
Maintainer: Henrik Bengtsson <henrikb@braju.com>
Description: High-performing functions operating on rows and columns of matrices, e.g. col / rowMedians(), col / rowRanks(), and col / rowSds(). Functions optimized per data type and for subsetted calculations such that both memory usage and processing time is minimized. There are also optimized vector-based methods, e.g. binMeans(), madDiff() and weightedMedian().
License: Artistic-2.0
......@@ -25,6 +33,6 @@ ByteCompile: TRUE
URL: https://github.com/HenrikBengtsson/matrixStats
BugReports: https://github.com/HenrikBengtsson/matrixStats/issues
RoxygenNote: 6.0.1
Packaged: 2017-04-13 07:54:02 UTC; hb
Packaged: 2018-02-10 18:37:02 UTC; hb
Repository: CRAN
Date/Publication: 2017-04-14 14:49:54 UTC
Date/Publication: 2018-02-11 14:13:37 UTC
This diff is collapsed.
Package: matrixStats
====================
Version: 0.53.1 [2018-02-10]
CODE REFACTORING:
o Now col-/rowSds() explicitly replicate all arguments that are passed to
col-/rowVars().
DOCUMENTATION:
o Added details on how weightedMedian(x, interpolate = TRUE) works.
BUG FIXES:
o colLogSumExps(lx, cols) / rowLogSumExps(lx, rows) gave an error if 'lx'
has rownames / colnames.
o col-/rowQuantiles() would lose rownames of output in certain cases.
Version: 0.53.0 [2018-01-23]
NEW FEATURES:
o Functions sum2(x) and means2(x) now accept also logical input 'x', which
corresponds to using as.integer(x) but without the need for neither coercion
nor internal extra copies. With sum2(x, mode = "double") it is possible to
count number of TRUE elements beyond 2^31-1, which base::sum() does not
support.
o Functions col-/rowSums2() and col-/rowMeans2() now accept also logical
input 'x'.
o Function binMeans(y, x, bx) now accepts logical 'y', which corresponds
to to using as.integer(y) but without the need for coercion to integer.
o Functions col-/rowTabulates(x) now support logical input 'x'.
o Now count() can count beyond 2^31-1.
o allocVector() can now allocate long vectors (longer than 2^31-1).
o Now sum2(x, mode = "integer") generates a warning if typeof(x) == "double"
asking if as.integer(sum2(x)) was intended.
o Inspired by Hmisc::wtd.var(), when sum(w) <= 1, now weightedVar(x, w)
produces an informative warning that the estimate is invalid.
CODE REFACTORING:
o Harmonized the ordering of the arguments of colAvgsPerColSet() with that
of rowAvgsPerColSet().
BUG FIXES:
o col-/rowLogSumExp() could core dump R for "large" number of columns/rows.
Thanks Brandon Stewart at Princeton University for reporting on this.
o count() beyond 2^31-1 would return invalid results.
o Functions col-/rowTabulates(x) did not count missing values.
o indexByRow(dim, idxs) would give nonsense results if 'idxs' had indices
greater than prod(dim) or non-positive indices; now it gives an error.
o indexByRow(dim) would give nonsense results when prod(dim) >= 2^31; now
it gives an informative error.
o col-/rowAvgsPerColSet() would return vector rather than matrix if
nrow(X) <= 1. Thanks to Peter Hickey (Johns Hopkins University) for
troubleshooting and providing a fix.
DEPRECATED AND DEFUNCT:
o Previously deprecated meanOver() and sumOver() are defunct. Use mean2()
and sum2() instead.
o Previously deprecated weightedVar(x, w, method = "0.14.2") is defunct.
o Dropped previously defunct weightedMedian(..., ties = "both").
o Dropped previously defunct argument 'centers' for col-/rowMads(). Use
'center' instead.
o Dropped previously defunct argument 'flavor' of colRanks() and rowRanks().
Version: 0.52.2 [2017-04-13]
BUG FIX:
BUG FIXES:
o Several of the row- and column-based functions would core dump R if the
matrix was of a data type other than logical, integer, or numeric, e.g.
......@@ -20,7 +106,7 @@ DEPRECATED AND DEFUNCT:
Version: 0.52.1 [2017-04-04]
BUG FIX:
BUG FIXES:
o The package test on matrixStats:::benchmark() tried to run even if
not all suggested packages were available.
......@@ -107,6 +193,14 @@ DEPRECATED AND DEFUNCT:
o Previously deprecated (and ignored) argument 'flavor' of colRanks() and
rowRanks() is now defunct.
o Previously deprecated support for passing non-vector, non-matrix objects
to rowAlls(), rowAnys(), rowCollapse(), and the corresponding column-based
versions are now defunct. Likewise, rowProds(), rowQuantiles(),
rowWeightedMeans(), rowWeightedMedians(), and the corresponding column-based
versions are also defunct. The rationale for this is to tighten up the
identity of the matrixStats package and what types of input it accepts.
This will also help optimize the code further.
Version: 0.51.0 [2016-10-08]
......@@ -185,6 +279,8 @@ DEPRECATED AND DEFUNCT:
o CLEANUP: Defunct argument 'centers' for col-/rowMads(); use 'center'.
o weightedVar(x, w, method = "0.14.2") is deprecated.
Version: 0.14.2 [2015-06-23]
......@@ -253,10 +349,10 @@ SIGNIFICANT CHANGES:
NEW FEATURES:
o CONSISTENCY: Renamed argument 'centers' of col- and rowMads() to 'center'.
This is consistent with col- and rowVars().
o CONSISTENCY: Renamed argument 'centers' of col-/rowMads() to 'center'.
This is consistent with col-/rowVars().
o CONSISTENCY: col- and rowVars() now use na.rm = FALSE as the default
o CONSISTENCY: col-/rowVars() now use na.rm = FALSE as the default
(na.rm = TRUE was mistakenly introduced as the default in v0.9.7).
PERFORMANCE AND MEMORY:
......@@ -289,9 +385,8 @@ BUG FIXES:
consistent with all() and any() if there were missing values. For
example, with x <- c("a", NA, "b") we have all(x == "a") == FALSE and
any(x == "a") == TRUE whereas our corresponding methods would return NA in
those cases. The methods fixed are allValue(), anyValue(), col- and
rowAlls(), and col- and rowAnys(). Added more package tests to cover
these cases.
those cases. The methods fixed are allValue(), anyValue(), col-/rowAlls(),
and col-/rowAnys(). Added more package tests to cover these cases.
o logSumExp(x, na.rm = TRUE) would return NA if all values were NA and
length(x) > 1. Now it returns -Inf for all length(x):s.
......@@ -347,7 +442,7 @@ NEW FEATURES:
DOCUMENTATION:
o DOCUMENTATION: Added vignette summarizing available functions.
o Added vignette summarizing available functions.
PERFORMANCE AND MEMORY:
......@@ -382,7 +477,11 @@ BUG FIXES:
o weightedMedian(..., ties = "both") would give an error if there was a tie.
Added package test for this case.
DEPRECATED AND DEFUNCT:
o weightedMedian(..., ties = "both") is now defunct.
Version: 0.12.2 [2014-12-07]
BUG FIXES:
......@@ -393,6 +492,10 @@ BUG FIXES:
least when validated on several local setups as well as on the CRAN servers).
Again, thanks to Brian Ripley for pointing out another invalid integer-double
coersion at the C level.
DEPRECATED AND DEFUNCT:
o weightedMedian(..., interpolate = FALSE, ties = "both") is defunct.
Version: 0.12.1 [2014-12-06]
......@@ -622,8 +725,8 @@ Version: 0.10.1 [2014-06-09]
PERFORMANCE AND MEMORY:
o Added benchmark reports for also non-matrixStats functions col/rowSums()
and col/rowMeans().
o Added benchmark reports for also non-matrixStats functions col-/rowSums()
and col-/rowMeans().
o Now all colNnn() and rowNnn() methods are benchmarked in a combined report
making it possible to also compare colNnn(x) with rowNnn(t(x)).
......@@ -649,8 +752,8 @@ Version: 0.9.7 [2014-06-05]
BUG FIXES:
o Introduced a bug in v0.9.5 causing col- and rowVars() and hence also
col- and rowSds() to return garbage. Add package tests for these now.
o Introduced a bug in v0.9.5 causing col-/rowVars() and hence also
col-/rowSds() to return garbage. Add package tests for these now.
o Submitted to CRAN.
......@@ -665,7 +768,7 @@ NEW FEATURES:
PERFORMANCE AND MEMORY:
o SPEEDUP: Now col- and rowProds() utilizes new product() function.
o SPEEDUP: Now col-/rowProds() utilizes new product() function.
o SPEEDUP: Added product() for calculating the product of a numeric
vector via the logarithm.
......@@ -684,8 +787,8 @@ SIGNIFICANT CHANGES:
NEW FEATURES:
o Added argument 'method' to col- and rowProds() for controlling how the
product is calculated.
o Added argument 'method' to col-/rowProds() for controlling how the product
is calculated.
PERFORMANCE AND MEMORY:
......
......@@ -34,7 +34,7 @@ allocMatrix <- function(nrow, ncol, value = 0.0, ...) {
#' @rdname allocMatrix
#' @export
allocVector <- function(length, value = 0.0, ...) {
length <- as.integer(length)
length <- as.numeric(length)
.Call(C_allocVector2, length, value)
}
......
......@@ -5,8 +5,8 @@
#' \code{binMeans(x, bx, right = TRUE)} gives equivalent results as
#' \code{rev(binMeans(-x, bx = sort(-bx), right = FALSE))}, but is faster.
#'
#' @param y A \code{\link[base]{numeric}} \code{\link[base]{vector}} of K
#' values to calculate means on.
#' @param y A \code{\link[base]{numeric}} or \code{\link[base]{logical}}
#' \code{\link[base]{vector}} of K values to calculate means on.
#'
#' @param x A \code{\link[base]{numeric}} \code{\link[base]{vector}} of K
#' positions for to be binned.
......@@ -58,11 +58,11 @@ binMeans <- function(y, x, idxs = NULL, bx, na.rm = TRUE, count = TRUE,
# Validate arguments
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Argument 'y':
if (!is.numeric(y)) {
stop("Argument 'y' is not numeric: ", mode(y))
if (!is.numeric(y) && !is.logical(y)) {
stop("Argument 'y' is neither numeric nor logical: ", mode(y))
}
if (any(is.infinite(y))) {
stop("Argument 'y' must not contain Inf values.")
if (is.numeric(y) && !is.integer(y) && any(is.infinite(y))) {
stop("Argument 'y' must not contain infinite values.")
}
n <- length(y)
......
......@@ -13,6 +13,14 @@
#' @return Returns an \code{\link[base]{integer}} \code{\link[base]{vector}} of
#' indices.
#'
#' @section Known limitations:
#' The current implementation does not support long-vector indices,
#' because both input and output indices are of type integers.
#' This means that the indices in argument \code{idxs} can only be in
#' range [1,2^31-1]. Using a greater value will be coerced to
#' \code{NA_integer_}. Moreover, returned indices can only be in the
#' same range [1,2^31-1].
#'
#' @example incl/indexByRow.R
#'
#' @author Henrik Bengtsson
......
......@@ -15,8 +15,8 @@
#' \code{mean2(..., refine = FALSE)} is almost twice as fast as
#' \code{mean2(..., refine = TRUE)}.
#'
#' @param x A \code{\link[base]{numeric}} \code{\link[base]{vector}} of length
#' N.
#' @param x A \code{\link[base]{numeric}} or \code{\link[base]{logical}}
#' \code{\link[base]{vector}} of length N.
#'
#' @param idxs A \code{\link[base]{vector}} indicating subset of elements to
#' operate over. If \code{\link[base]{NULL}}, no subsetting is done.
......@@ -45,8 +45,8 @@ mean2 <- function(x, idxs = NULL, na.rm = FALSE, refine = TRUE, ...) {
# Validate arguments
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Argument 'x':
if (!is.numeric(x)) {
stop("Argument 'x' is not numeric: ", mode(x))
if (!is.numeric(x) && !is.logical(x)) {
stop("Argument 'x' is neither numeric nor logical: ", mode(x))
}
# Argument 'na.rm':
......@@ -68,6 +68,5 @@ mean2 <- function(x, idxs = NULL, na.rm = FALSE, refine = TRUE, ...) {
#' @rdname mean2
#' @export
meanOver <- function(...) {
.Deprecated(new = "mean2")
mean2(...)
.Defunct(new = "mean2")
}
......@@ -61,7 +61,7 @@ rowAlls <- function(x, rows = NULL, cols = NULL, value = TRUE,
if (is.vector(x)) {
dim(x) <- dim.
} else if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......@@ -99,7 +99,7 @@ colAlls <- function(x, rows = NULL, cols = NULL, value = TRUE,
if (is.vector(x)) {
dim(x) <- dim.
} else if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......@@ -165,7 +165,7 @@ rowAnys <- function(x, rows = NULL, cols = NULL, value = TRUE,
if (is.vector(x)) {
dim(x) <- dim.
} else if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......@@ -203,7 +203,7 @@ colAnys <- function(x, rows = NULL, cols = NULL, value = TRUE,
if (is.vector(x)) {
dim(x) <- dim.
} else if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......
......@@ -128,6 +128,13 @@ rowAvgsPerColSet <- function(X, W = NULL, rows = NULL, S,
Zjj
})
# apply() drops 2nd dimension if nrow(X) <= 1 (and FUN returns a vector of
# length nrow(X) as it should), cf. ?apply
if (!is.matrix(Z)) {
stopifnot(dimX[1] <= 1L)
dim(Z) <- c(length(Z), nbrOfSets)
}
# Sanity check
stopifnot(dim(Z) == c(dimX[1L], nbrOfSets))
......@@ -141,7 +148,7 @@ rowAvgsPerColSet <- function(X, W = NULL, rows = NULL, S,
#' @rdname rowAvgsPerColSet
#' @export
colAvgsPerRowSet <- function(X, W = NULL, cols = NULL, S,
FUN = colMeans, tFUN = FALSE, ...) {
FUN = colMeans, ..., tFUN = FALSE) {
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Validate arguments
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......@@ -183,7 +190,7 @@ colAvgsPerRowSet <- function(X, W = NULL, cols = NULL, S,
}
# ...
tZ <- rowAvgsPerColSet(X = tX, W = tW, S = S, FUN = FUN, tFUN = !tFUN, ...)
tZ <- rowAvgsPerColSet(X = tX, W = tW, S = S, FUN = FUN, ..., tFUN = !tFUN)
tX <- tW <- NULL # Not needed anymore
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
......
......@@ -31,7 +31,7 @@
rowCollapse <- function(x, idxs, rows = NULL, dim. = dim(x), ...) {
# Argument 'x':
if (!is.matrix(x) && !is.vector(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......@@ -61,7 +61,7 @@ rowCollapse <- function(x, idxs, rows = NULL, dim. = dim(x), ...) {
colCollapse <- function(x, idxs, cols = NULL, dim. = dim(x), ...) {
# Argument 'x':
if (!is.matrix(x) && !is.vector(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix or a vector. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......
#' Counts the number of TRUE values in each row (column) of a matrix
#' Counts the number of occurrences of a specific value
#'
#' Counts the number of TRUE values in each row (column) of a matrix.
#'
#' These functions takes either a matrix or a vector as input. If a vector,
#' then argument \code{dim.} must be specified and fulfill \code{prod(dim.) ==
#' length(x)}. The result will be identical to the results obtained when
#' passing \code{matrix(x, nrow = dim.[1L], ncol = dim.[2L])}, but avoids
#' having to temporarily create/allocate a matrix, if only such is needed
#' only for these calculations.
#' The row- and column-wise functions take either a matrix or a vector as
#' input. If a vector, then argument \code{dim.} must be specified and fulfill
#' \code{prod(dim.) == length(x)}. The result will be identical to the results
#' obtained when passing \code{matrix(x, nrow = dim.[1L], ncol = dim.[2L])},
#' but avoids having to temporarily create/allocate a matrix, if only such is
#' needed only for these calculations.
#'
#' @param x An NxK \code{\link[base]{matrix}} or an N * K
#' \code{\link[base]{vector}}.
......@@ -29,6 +27,9 @@
#'
#' @return \code{rowCounts()} (\code{colCounts()}) returns an
#' \code{\link[base]{integer}} \code{\link[base]{vector}} of length N (K).
#' \code{count()} returns a scalar of type \code{\link[base]{integer}} if
#' the count is less than 2^31-1 (= \code{.Machine$integer.max}) otherwise
#' a scalar of type \code{\link[base]{double}}.
#'
#' @example incl/rowCounts.R
#'
......@@ -73,7 +74,9 @@ rowCounts <- function(x, rows = NULL, cols = NULL, value = TRUE,
dim. <- dim(x)
if (is.na(value)) {
counts <- apply(x, MARGIN = 1L, FUN = function(x) sum(is.na(x)))
counts <- apply(x, MARGIN = 1L, FUN = function(x) {
sum(is.na(x))
})
} else {
counts <- apply(x, MARGIN = 1L, FUN = function(x) {
sum(x == value, na.rm = na.rm)
......@@ -166,11 +169,11 @@ count <- function(x, idxs = NULL, value = TRUE, na.rm = FALSE, ...) {
if (!is.null(idxs)) x <- x[idxs]
if (is.na(value)) {
counts <- sum(is.na(x))
counts <- sum2(is.na(x))
} else {
counts <- sum(x == value, na.rm = na.rm)
counts <- sum2(x == value, na.rm = na.rm)
}
}
as.integer(counts)
counts
}
......@@ -45,6 +45,9 @@ rowLogSumExps <- function(lx, rows = NULL, cols = NULL, na.rm = FALSE,
# Preserve names
names <- rownames(lx)
if (!is.null(names)) {
if (!is.null(rows)) {
names <- names[rows]
}
names(res) <- names
}
......@@ -64,6 +67,9 @@ colLogSumExps <- function(lx, rows = NULL, cols = NULL, na.rm = FALSE,
# Preserve names
names <- colnames(lx)
if (!is.null(names)) {
if (!is.null(cols)) {
names <- names[cols]
}
names(res) <- names
}
......
#' @param constant A scale factor. See \code{\link[stats]{mad}} for details.
#'
#' @rdname rowSds
#' @export
rowMads <- function(x, rows = NULL, cols = NULL, center = NULL,
constant = 1.4826, na.rm = FALSE,
dim. = dim(x), centers = NULL, ...) {
## BACKWARD COMPATIBILITY:
## - Added to matrixStats 0.14.0.
## - Defunct in matrixStats (>= 0.15.0)
if (!is.null(centers)) {
center <- centers
.Defunct(msg = "Argument 'centers' for matrixStats::rowMads() has been renamed to 'center'. Please update code accordingly.") #nolint
}
dim. = dim(x), ...) {
if (is.null(center)) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
......@@ -42,15 +36,7 @@ rowMads <- function(x, rows = NULL, cols = NULL, center = NULL,
#' @export
colMads <- function(x, rows = NULL, cols = NULL, center = NULL,
constant = 1.4826, na.rm = FALSE,
dim. = dim(x), centers = NULL, ...) {
## BACKWARD COMPATIBILITY:
## - Added to matrixStats 0.14.0.
## - Defunct in matrixStats (>= 0.15.0)
if (!is.null(centers)) {
center <- centers
.Defunct(msg = "Argument 'centers' for matrixStats::colMads() has been renamed to 'center'. Please update code accordingly.") #nolint
}
dim. = dim(x), ...) {
if (is.null(center)) {
dim. <- as.integer(dim.)
na.rm <- as.logical(na.rm)
......
......@@ -5,7 +5,8 @@
#' The implementation of \code{rowMeans2()} and \code{colMeans2()} is
#' optimized for both speed and memory.
#'
#' @param x A \code{\link[base]{numeric}} NxK \code{\link[base]{matrix}}.
#' @param x A \code{\link[base]{numeric}} or a \code{\link[base]{logical}}
#' NxK \code{\link[base]{matrix}}.
#'
#' @param rows,cols A \code{\link[base]{vector}} indicating subset of rows
#' (and/or columns) to operate over. If \code{\link[base]{NULL}}, no subsetting
......
......@@ -31,9 +31,10 @@
#'
#' @author Henrik Bengtsson, Harris Jaffee
#'
#' @seealso See \code{\link{rowMedians}}() and \code{colMedians()} for weighted
#' medians. For mean estimates, see \code{rowMeans()} in
#' \code{\link[base]{colSums}}().
#' @seealso See \code{\link{rowWeightedMedians}()} and
#' \code{colWeightedMedians()} for weighted medians.
#' For mean estimates, see \code{\link{rowMeans2}()} and
#' \code{\link[base:colSums]{rowMeans}()}.
#'
#' @keywords array iteration robust univar
#' @export
......
......@@ -42,7 +42,7 @@ rowProds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE,
method = c("direct", "expSumLog"), ...) {
# Argument 'x':
if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......@@ -82,7 +82,7 @@ colProds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE,
method = c("direct", "expSumLog"), ...) {
# Argument 'x':
if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Apply subset
......
......@@ -40,7 +40,7 @@ rowQuantiles <- function(x, rows = NULL, cols = NULL,
na.rm = FALSE, type = 7L, ..., drop = TRUE) {
# Argument 'x':
if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Argument 'probs':
......@@ -117,9 +117,11 @@ rowQuantiles <- function(x, rows = NULL, cols = NULL,
q <- matrix(na_value, nrow = nrow, ncol = length(probs))
}
# Add names
# Add dim names
digits <- max(2L, getOption("digits"))
colnames(q) <- sprintf("%.*g%%", digits, 100 * probs)
rownames(q) <- rownames(x)
# Drop singleton dimensions?
if (drop) {
q <- drop(q)
......@@ -136,7 +138,7 @@ colQuantiles <- function(x, rows = NULL, cols = NULL,
na.rm = FALSE, type = 7L, ..., drop = TRUE) {
# Argument 'x':
if (!is.matrix(x)) {
.Deprecated(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed, and will be defunct (produce an error) in a future version of matrixStats. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
.Defunct(msg = sprintf("Argument 'x' is of class %s, but should be a matrix. The use of a %s is not supported, the correctness of the result is not guaranteed. Please update your code accordingly.", sQuote(class(x)[1]), sQuote(class(x)[1]))) #nolint
}
# Argument 'probs':
......@@ -206,16 +208,17 @@ colQuantiles <- function(x, rows = NULL, cols = NULL,
if (na.rm) xkk <- xkk[!is.na(xkk)]
q[kk, ] <- quantile(xkk, probs = probs, na.rm = FALSE, type = type, ...)
}
} # if (type ...)
} # if (type ...)
} else {
na_value <- NA_real_
storage.mode(na_value) <- storage.mode(x)
q <- matrix(na_value, nrow = ncol, ncol = length(probs))
}
# Add names
# Add dim names
digits <- max(2L, getOption("digits"))
colnames(q) <- sprintf("%.*g%%", digits, 100 * probs)
rownames(q) <- colnames(x)
# Drop singleton dimensions?
if (drop) {
......
......@@ -68,11 +68,6 @@ rowRanks <- function(x, rows = NULL, cols = NULL,
# Argument 'ties.method':
ties.method <- ties.method[1L]
if (is.element("flavor", names(list(...)))) {
.Defunct(msg = "Argument 'flavor' of rowRanks() is defunct.",
package = "matrixStats")
}
ties_method <- charmatch(ties.method, c("max", "average", "min"),
nomatch = 0L)
if (ties_method == 0L) {
......@@ -93,11 +88,6 @@ colRanks <- function(x, rows = NULL, cols = NULL,
# Argument 'ties.method':
ties.method <- ties.method[1L]
if (is.element("flavor", names(list(...)))) {
.Defunct(msg = "Argument 'flavor' of colRanks() is defunct.",
package = "matrixStats")
}
# Argument 'preserveShape'
preserveShape <- as.logical(preserveShape)
......
......@@ -9,23 +9,18 @@
#' (and/or columns) to operate over. If \code{\link[base]{NULL}}, no subsetting
#' is done.
#'
#' @param center A optional \code{\link[base]{numeric}}
#' \code{\link[base]{vector}} of length N (K) with centers. By default, they
#' are calculated using \code{\link{rowMedians}}().
#' @param na.rm If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s
#' are excluded first, otherwise not.
#'
#' @param constant A scale factor. See \code{\link[stats]{mad}} for details.
#'
#' @param na.rm If \code{\link[base:logical]{TRUE}}, missing values are removed
#' first, otherwise not.
#' @param center (optional) The center, defaults to the row means for the
#' SD estimators and row medians for the MAD estimators.
#'
#' @param dim. An \code{\link[base]{integer}} \code{\link[base]{vector}} of
#' length two specifying the dimension of \code{x}, also when not a
#' \code{\link[base]{matrix}}.
#'
#' @param ... Additional arguments passed to \code{\link{rowVars}}() and
#' \code{\link{rowMedians}}(), respectively.
#'
#' @param centers (deprectated) use \code{center} instead.
#' @param ... Additional arguments passed to \code{rowMeans()} and
#' \code{rowSums()}.
#'
#' @return Returns a \code{\link[base]{numeric}} \code{\link[base]{vector}} of
#' length N (K).
......@@ -37,15 +32,17 @@
#' @keywords array iteration robust univar
#'
#' @export
rowSds <- function(x, rows = NULL, cols = NULL, ...) {
x <- rowVars(x, rows = rows, cols = cols, ...)
rowSds <- function(x, rows = NULL, cols = NULL, na.rm = FALSE, center = NULL,