inst/tinytest/runit.rowSums-rowMeans.R

test.rowSums_dispatch <- function() {
  x <- xts(cbind(1:3, 4:6), .Date(1:3))
  y <- xts(base::rowSums(x), index(x))
  checkEqualsNumeric(y, rowSums(x))
  checkEquals(index(y), index(x))

  d <- data.frame(x)
  v <- as.vector(y)
  checkEqualsNumeric(v, rowSums(d))
  checkEquals(rownames(d), as.character(index(x)))
}

test.rowMeans_dispatch <- function() {
  x <- xts(cbind(1:3, 4:6), .Date(1:3))
  y <- xts(base::rowMeans(x), index(x))
  checkEqualsNumeric(y, rowMeans(x))
  checkEquals(index(y), index(x))

  d <- data.frame(x)
  v <- as.vector(y)
  checkEqualsNumeric(v, rowMeans(d))
  checkEquals(rownames(d), as.character(index(x)))
}

Try the xts package in your browser

Any scripts or data that you put into this service are public.

xts documentation built on April 17, 2023, 1:07 a.m.