diff --git a/R/expect-shape.R b/R/expect-shape.R index 741bd086a..4f35d1156 100644 --- a/R/expect-shape.R +++ b/R/expect-shape.R @@ -8,7 +8,7 @@ #' @inheritParams expect_that #' @param ... Ignored. #' @param length Expected [length()] of `object`. -#' @param nrow,nrow Expected [nrow()]/[ncol()] of `object`. +#' @param nrow,ncol Expected [nrow()]/[ncol()] of `object`. #' @param dim Expected [dim()] of `object`. #' @family expectations #' @export diff --git a/man/expect_shape.Rd b/man/expect_shape.Rd index 064750fcd..9abb9da22 100644 --- a/man/expect_shape.Rd +++ b/man/expect_shape.Rd @@ -16,9 +16,7 @@ within a function or for loop. See \link{quasi_label} for more details.} \item{length}{Expected \code{\link[=length]{length()}} of \code{object}.} -\item{nrow}{Expected \code{\link[=nrow]{nrow()}} of \code{object}.} - -\item{ncol}{Expected \code{\link[=ncol]{ncol()}} of \code{object}.} +\item{nrow, ncol}{Expected \code{\link[=nrow]{nrow()}}/\code{\link[=ncol]{ncol()}} of \code{object}.} \item{dim}{Expected \code{\link[=dim]{dim()}} of \code{object}.} } @@ -26,6 +24,13 @@ within a function or for loop. See \link{quasi_label} for more details.} This is a generalization of \code{\link[=expect_length]{expect_length()}} to test the "shape" of more general objects like data.frames, matrices, and arrays. } +\examples{ +x <- matrix(1:9, nrow = 3) +expect_shape(x, length = 9) +expect_shape(x, nrow = 3) +expect_shape(x, ncol = 3) +expect_shape(x, dim = c(3, 3)) +} \seealso{ \code{\link[=expect_length]{expect_length()}} to specifically make assertions about the \code{\link[=length]{length()}} of a vector.