-
Notifications
You must be signed in to change notification settings - Fork 318
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
testthat fails, yet same code works in a standard test #322
Comments
This fails directly for me (ie, is not a
Either way, do you really want to override the generic? Can't you just implement a |
That's true. But install_github("hofnerb/papeR")
library("papeR")
labels
labels(matrix(1:10)) does work, though. In essence I currently do not need to overwrite the standard generic. However, I wanted to add a special behaviour such that I can extract variable labels by df <- data.frame(x = 1:3, y = 4:6)
df <- as.ldf(df)
labels(df$x) which should return attr(df$x, "variable.label") I was thinking of something along the lines of labels.default <- function(object, ...) {
if (!is.null(attr(object, "variable.label"))) {
return(attr(object, "variable.label"))
}
UseMethod("base::labels")
} which wouldn't change standard behaviour per se. [We had this discussion already elsewhere btw]. However, I was just thinking to also give a new (additional) class to all "columns" of the data frame to allow method dispatch to work. Still, I am puzzled why this happens that way. |
I think you want |
In my package papeR I have the following lines in my code
If I am using
in a standard file in
tests
, e.g. intests/regtest-prettify.R
everything works as expected and I getThe same is true if I run the code after installing the package.
Yet, if I put this code in
tests/testthat/test-labels.R
, I get (essentially) the following errorNow, I wonder
a) why this happens
b) why this happens only with testthat
c) how I can debug and solve this.
The text was updated successfully, but these errors were encountered: