This makes sparseMatrixStats compatible with v0.60 of matrixStats

In this commit
* I introduce a set of function called set_result_names()
that take the internally computed result and add correct names if needed
* Add colnames to the matrices of the unit tests
* Update the documentation to reflect the changed method signatures

const-ae authored on 05/08/2021 13:05:38
Showing 1 changed files
 ... ... @@ -6,9 +6,25 @@ 6 6  \title{Calculates the variance of the difference between each element of a row 7 7  (column) of a matrix-like object} 8 8  \usage{ 9 -\S4method{colVarDiffs}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0) 9 +\S4method{colVarDiffs}{dgCMatrix}( 10 + x, 11 + rows = NULL, 12 + cols = NULL, 13 + na.rm = FALSE, 14 + diff = 1L, 15 + trim = 0, 16 + useNames = NA 17 +) 10 18   11 -\S4method{rowVarDiffs}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0) 19 +\S4method{rowVarDiffs}{dgCMatrix}( 20 + x, 21 + rows = NULL, 22 + cols = NULL, 23 + na.rm = FALSE, 24 + diff = 1L, 25 + trim = 0, 26 + useNames = NA 27 +) 12 28  } 13 29  \arguments{ 14 30  \item{x}{An NxK matrix-like object.} ... ... @@ -28,6 +44,8 @@ are excluded first, otherwise not.} 28 44   29 45  \item{trim}{A double in [0,1/2] specifying the fraction of observations to 30 46  be trimmed from each end of (sorted) x before estimation.} 47 + 48 +\item{useNames}{If \code{\link{NA}}, the default behavior of the function about naming support is remained. If \code{\link{FALSE}}, no naming support is done. Else if \code{\link{TRUE}}, names attributes of result are set.} 31 49  } 32 50  \value{ 33 51  Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K).

const-ae authored on 24/05/2020 11:09:17
Showing 1 changed files
 ... ... @@ -55,8 +55,8 @@ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) 55 55  } 56 56  \seealso{ 57 57  \itemize{ 58 -\item \code{matrixStats::\link[matrixStats]{rowVarDiffs}()} and 59 -\code{matrixStats::\link[matrixStats:rowVarDiffs]{colVarDiffs}()} which 58 +\item \code{matrixStats::\link[matrixStats:varDiff]{rowVarDiffs}()} and 59 +\code{matrixStats::\link[matrixStats:varDiff]{colVarDiffs}()} which 60 60  are used when the input is a \code{matrix} or \code{numeric} vector. 61 61  \item for the direct variance see \code{\link[MatrixGenerics:rowVars]{rowVars()}}. 62 62  }

const-ae authored on 21/05/2020 11:07:40
Showing 1 changed files
 ... ... @@ -39,8 +39,8 @@ Calculates the variance of the difference between each element of a row 39 39  \details{ 40 40  The S4 methods for \code{x} of type \code{\link{matrix}}, 41 41  \code{\link{array}}, or \code{\link{numeric}} call 42 -\code{matrixStats::\link[matrixStats]{rowVarDiffs}} 43 -/ \code{matrixStats::\link[matrixStats:rowVarDiffs]{colVarDiffs}}. 42 +\code{matrixStats::rowVarDiffs} 43 +/ \code{matrixStats::colVarDiffs}. 44 44  } 45 45  \examples{ 46 46  mat <- matrix(rnorm(15), nrow = 5, ncol = 3)

#### Bring documentation in line with updates from MatrixGenerics

See https://github.com/Bioconductor/MatrixGenerics/issues/11

const-ae authored on 24/04/2020 07:36:21
Showing 1 changed files
 ... ... @@ -13,15 +13,15 @@ 13 13  \arguments{ 14 14  \item{x}{An NxK matrix-like object.} 15 15   16 -\item{rows}{A \code{\link[base]{vector}} indicating the subset of rows 17 -(and/or columns) to operate over. If \code{\link[base]{NULL}}, no 18 -subsetting is done.} 16 +\item{rows}{A \code{\link{vector}} indicating the subset of rows 17 +(and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is 18 +done.} 19 19   20 -\item{cols}{A \code{\link[base]{vector}} indicating the subset of rows 21 -(and/or columns) to operate over. If \code{\link[base]{NULL}}, no 22 -subsetting is done.} 20 +\item{cols}{A \code{\link{vector}} indicating the subset of rows 21 +(and/or columns) to operate over. If \code{\link{NULL}}, no subsetting is 22 +done.} 23 23   24 -\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s 24 +\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link{NA}}s 25 25  are excluded first, otherwise not.} 26 26   27 27  \item{diff}{An integer specifying the order of difference.} ... ... @@ -30,18 +30,17 @@ are excluded first, otherwise not.} 30 30  be trimmed from each end of (sorted) x before estimation.} 31 31  } 32 32  \value{ 33 -Returns a \code{\link[base]{numeric}} \code{\link[base]{vector}} of 34 -length N (K). 33 +Returns a \code{\link{numeric}} \code{\link{vector}} of length N (K). 35 34  } 36 35  \description{ 37 36  Calculates the variance of the difference between each element of a row 38 37  (column) of a matrix-like object. 39 38  } 40 39  \details{ 41 -The S4 methods for \code{x} of type \code{\link[base]{matrix}}, 42 -\code{\link[base]{array}}, or \code{\link[base]{numeric}} call 40 +The S4 methods for \code{x} of type \code{\link{matrix}}, 41 +\code{\link{array}}, or \code{\link{numeric}} call 43 42  \code{matrixStats::\link[matrixStats]{rowVarDiffs}} 44 -/ \code{matrixStats::\link[matrixStats]{colVarDiffs}}. 43 +/ \code{matrixStats::\link[matrixStats:rowVarDiffs]{colVarDiffs}}. 45 44  } 46 45  \examples{ 47 46  mat <- matrix(rnorm(15), nrow = 5, ncol = 3) ... ... @@ -57,8 +56,8 @@ mat <- matrix(rnorm(15), nrow = 5, ncol = 3) 57 56  \seealso{ 58 57  \itemize{ 59 58  \item \code{matrixStats::\link[matrixStats]{rowVarDiffs}()} and 60 -\code{matrixStats::\link[matrixStats]{colVarDiffs}()} which are used when 61 -the input is a \code{matrix} or \code{numeric} vector. 59 +\code{matrixStats::\link[matrixStats:rowVarDiffs]{colVarDiffs}()} which 60 +are used when the input is a \code{matrix} or \code{numeric} vector. 62 61  \item for the direct variance see \code{\link[MatrixGenerics:rowVars]{rowVars()}}. 63 62  } 64 63  }

#### Remove superfluous ... from method signatures

const-ae authored on 03/04/2020 10:39:05
Showing 1 changed files
 ... ... @@ -6,25 +6,9 @@ 6 6  \title{Calculates the variance of the difference between each element of a row 7 7  (column) of a matrix-like object} 8 8  \usage{ 9 -\S4method{colVarDiffs}{dgCMatrix}( 10 - x, 11 - rows = NULL, 12 - cols = NULL, 13 - na.rm = FALSE, 14 - diff = 1L, 15 - trim = 0, 16 - ... 17 -) 9 +\S4method{colVarDiffs}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0) 18 10   19 -\S4method{rowVarDiffs}{dgCMatrix}( 20 - x, 21 - rows = NULL, 22 - cols = NULL, 23 - na.rm = FALSE, 24 - diff = 1L, 25 - trim = 0, 26 - ... 27 -) 11 +\S4method{rowVarDiffs}{dgCMatrix}(x, rows = NULL, cols = NULL, na.rm = FALSE, diff = 1L, trim = 0) 28 12  } 29 13  \arguments{ 30 14  \item{x}{An NxK matrix-like object.} ... ... @@ -44,8 +28,6 @@ are excluded first, otherwise not.} 44 28   45 29  \item{trim}{A double in [0,1/2] specifying the fraction of observations to 46 30  be trimmed from each end of (sorted) x before estimation.} 47 - 48 -\item{...}{Additional arguments passed to specific methods.} 49 31  } 50 32  \value{ 51 33  Returns a \code{\link[base]{numeric}} \code{\link[base]{vector}} of

#### Bring documentation in line with MatrixGenerics

const-ae authored on 03/04/2020 10:19:46
Showing 1 changed files
 ... ... @@ -3,7 +3,8 @@ 3 3  \name{colVarDiffs,dgCMatrix-method} 4 4  \alias{colVarDiffs,dgCMatrix-method} 5 5  \alias{rowVarDiffs,dgCMatrix-method} 6 -\title{Calculates the variance of the difference between each element of a row (column) of a matrix-like object} 6 +\title{Calculates the variance of the difference between each element of a row 7 +(column) of a matrix-like object} 7 8  \usage{ 8 9  \S4method{colVarDiffs}{dgCMatrix}( 9 10  x, ... ... @@ -28,19 +29,21 @@ 28 29  \arguments{ 29 30  \item{x}{An NxK matrix-like object.} 30 31   31 -\item{rows}{A \code{\link[base]{vector}} indicating the subset (and/or 32 -columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} 32 +\item{rows}{A \code{\link[base]{vector}} indicating the subset of rows 33 +(and/or columns) to operate over. If \code{\link[base]{NULL}}, no 34 +subsetting is done.} 33 35   34 -\item{cols}{A \code{\link[base]{vector}} indicating the subset (and/or 35 -columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} 36 +\item{cols}{A \code{\link[base]{vector}} indicating the subset of rows 37 +(and/or columns) to operate over. If \code{\link[base]{NULL}}, no 38 +subsetting is done.} 36 39   37 40  \item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s 38 41  are excluded first, otherwise not.} 39 42   40 43  \item{diff}{An integer specifying the order of difference.} 41 44   42 -\item{trim}{A double in [0,1/2] specifying the fraction of observations to be trimmed from 43 -each end of (sorted) x before estimation.} 45 +\item{trim}{A double in [0,1/2] specifying the fraction of observations to 46 +be trimmed from each end of (sorted) x before estimation.} 44 47   45 48  \item{...}{Additional arguments passed to specific methods.} 46 49  } ... ... @@ -49,11 +52,13 @@ Returns a \code{\link[base]{numeric}} \code{\link[base]{vector}} of 49 52  length N (K). 50 53  } 51 54  \description{ 52 -Calculates the variance of the difference between each element of a row (column) of a matrix-like object 55 +Calculates the variance of the difference between each element of a row 56 +(column) of a matrix-like object. 53 57  } 54 58  \details{ 55 -The S4 methods for \code{x} of type \code{\link[base]{matrix}} or 56 -\code{\link[base]{numeric}} call \code{matrixStats::\link[matrixStats]{rowVarDiffs}} 59 +The S4 methods for \code{x} of type \code{\link[base]{matrix}}, 60 +\code{\link[base]{array}}, or \code{\link[base]{numeric}} call 61 +\code{matrixStats::\link[matrixStats]{rowVarDiffs}} 57 62  / \code{matrixStats::\link[matrixStats]{colVarDiffs}}. 58 63  } 59 64  \examples{

#### Use MatrixGenerics for all rowXXX functions

const-ae authored on 16/03/2020 20:22:08
Showing 1 changed files
 1 1 new file mode 100644 ... ... @@ -0,0 +1,77 @@ 1 +% Generated by roxygen2: do not edit by hand 2 +% Please edit documentation in R/methods.R, R/methods_row.R 3 +\name{colVarDiffs,dgCMatrix-method} 4 +\alias{colVarDiffs,dgCMatrix-method} 5 +\alias{rowVarDiffs,dgCMatrix-method} 6 +\title{Calculates the variance of the difference between each element of a row (column) of a matrix-like object} 7 +\usage{ 8 +\S4method{colVarDiffs}{dgCMatrix}( 9 + x, 10 + rows = NULL, 11 + cols = NULL, 12 + na.rm = FALSE, 13 + diff = 1L, 14 + trim = 0, 15 + ... 16 +) 17 + 18 +\S4method{rowVarDiffs}{dgCMatrix}( 19 + x, 20 + rows = NULL, 21 + cols = NULL, 22 + na.rm = FALSE, 23 + diff = 1L, 24 + trim = 0, 25 + ... 26 +) 27 +} 28 +\arguments{ 29 +\item{x}{An NxK matrix-like object.} 30 + 31 +\item{rows}{A \code{\link[base]{vector}} indicating the subset (and/or 32 +columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} 33 + 34 +\item{cols}{A \code{\link[base]{vector}} indicating the subset (and/or 35 +columns) to operate over. If \code{\link[base]{NULL}}, no subsetting is done.} 36 + 37 +\item{na.rm}{If \code{\link[base:logical]{TRUE}}, \code{\link[base]{NA}}s 38 +are excluded first, otherwise not.} 39 + 40 +\item{diff}{An integer specifying the order of difference.} 41 + 42 +\item{trim}{A double in [0,1/2] specifying the fraction of observations to be trimmed from 43 +each end of (sorted) x before estimation.} 44 + 45 +\item{...}{Additional arguments passed to specific methods.} 46 +} 47 +\value{ 48 +Returns a \code{\link[base]{numeric}} \code{\link[base]{vector}} of 49 +length N (K). 50 +} 51 +\description{ 52 +Calculates the variance of the difference between each element of a row (column) of a matrix-like object 53 +} 54 +\details{ 55 +The S4 methods for \code{x} of type \code{\link[base]{matrix}} or 56 +\code{\link[base]{numeric}} call \code{matrixStats::\link[matrixStats]{rowVarDiffs}} 57 +/ \code{matrixStats::\link[matrixStats]{colVarDiffs}}. 58 +} 59 +\examples{ 60 +mat <- matrix(rnorm(15), nrow = 5, ncol = 3) 61 + mat[2, 1] <- NA 62 + mat[3, 3] <- Inf 63 + mat[4, 1] <- 0 64 +  65 + print(mat) 66 +  67 + rowVarDiffs(mat) 68 + colVarDiffs(mat) 69 +} 70 +\seealso{ 71 +\itemize{ 72 +\item \code{matrixStats::\link[matrixStats]{rowVarDiffs}()} and 73 +\code{matrixStats::\link[matrixStats]{colVarDiffs}()} which are used when 74 +the input is a \code{matrix} or \code{numeric} vector. 75 +\item for the direct variance see \code{\link[MatrixGenerics:rowVars]{rowVars()}}. 76 +} 77 +}