diff --git a/CRAN-RELEASE b/CRAN-RELEASE index 629d26a..c8b72f3 100644 --- a/CRAN-RELEASE +++ b/CRAN-RELEASE @@ -1,2 +1,2 @@ -This package was submitted to CRAN on 2021-12-01. -Once it is accepted, delete this file and tag the release (commit a88ce56). +This package was submitted to CRAN on 2021-12-02. +Once it is accepted, delete this file and tag the release (commit 42b16b0). diff --git a/R/index0.R b/R/index0.R index afb14c6..a2d9038 100644 --- a/R/index0.R +++ b/R/index0.R @@ -3,6 +3,8 @@ #' Normally R is indexed from 1, but with the special `index0` class, you can #' have vectors that are indexed from zero. Works both for subsetting (extraction) #' and (sub-)assignment. +#' An `index0` object is just like a normal vector or matrix, but `x[i]` returns +#' or replaces the `(i+1)`th index. #' #' Assign the class `index0` to a vector, using `as.index0()` or `index_from_0()`, #' then use the subset operators normally and they will be indexed from zero. @@ -29,6 +31,18 @@ #' m[0, 1] #' m[0, 1] <- 99 #' m +#' +#' @return +#' `as.index0` returns the input (typically a vector or matrix) unchanged except +#' for the addition of an `index0` class attribute, which enables the zero-based +#' indexing behaviour. Use `as.index1` to remove this class again, if present. +#' +#' If `x` is a zero-indexed object with class `index0`, then `x[i]` returns an +#' appropriate subset of `x`. The returned subset is also zero-indexed. +#' `x[i] <- value` changes the `i`th element (effectively `(i+1)`th element in +#' ordinary R code) in place. +#' +#' `is.index0(x)` returns `TRUE` if `x` is indexed from zero, otherwise `FALSE`. #' #' @source #' Partially inspired by this Stack Overflow answer: diff --git a/cran-comments.md b/cran-comments.md index 858617d..1c6e7a6 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -2,4 +2,5 @@ 0 errors | 0 warnings | 1 note -* This is a new release. +* This is (a resubmission of) a new release. +* Details have been added to `\value` for the S3 class diff --git a/man/index0.Rd b/man/index0.Rd index d21aa5f..1e08afb 100644 --- a/man/index0.Rd +++ b/man/index0.Rd @@ -38,10 +38,24 @@ index_from_0(x) \item{value}{typically an array-like \R object of a similar class as \code{x}.} } +\value{ +\code{as.index0} returns the input (typically a vector or matrix) unchanged except +for the addition of an \code{index0} class attribute, which enables the zero-based +indexing behaviour. Use \code{as.index1} to remove this class again, if present. + +If \code{x} is a zero-indexed object with class \code{index0}, then \code{x[i]} returns an +appropriate subset of \code{x}. The returned subset is also zero-indexed. +\code{x[i] <- value} changes the \code{i}th element (effectively \code{(i+1)}th element in +ordinary R code) in place. + +\code{is.index0(x)} returns \code{TRUE} if \code{x} is indexed from zero, otherwise \code{FALSE}. +} \description{ Normally R is indexed from 1, but with the special \code{index0} class, you can have vectors that are indexed from zero. Works both for subsetting (extraction) and (sub-)assignment. +An \code{index0} object is just like a normal vector or matrix, but \code{x[i]} returns +or replaces the \code{(i+1)}th index. } \details{ Assign the class \code{index0} to a vector, using \code{as.index0()} or \code{index_from_0()},