I am confused about something. when I put this function into a package
oddTranspose <- function(x) {
t(x)
}
it works fine
m <- matrix(c(1,0,0,0), nrow=2)
M <- as(m, "Matrix")
oddTranspose(m) # works
oddTranspose(M) # works
but then, when I use devtools::test(), it stops working
devtools::test()
oddTranspose(m) # works
oddTranspose(M)
## t.default(x) : argument is not a matrix
This is problematic for me because I test my packages with the following work flow:
build the package, putting a file called
package_root\tests\testthat_tests.R, with the body
require(testthat)
require(myPackage)
test_check('myPackage')
and then in
package_root\tests\testthat\file.R, I put tests
I then test them in R with
library(testthat)
setwd("package_root/tests")
devtools::test()
what can I do?
Note that I spared you all of the text of my package overhead but the package's NAMESPACE imports the Matrix package and exports oddTranspose, and that the package DESCRIPTION "depends" on Matrix.