easystats
easystats copied to clipboard
Suppress (or attend to) warnings and messages in examples
Follow-up on https://github.com/easystats/easystats/issues/338
The check-all-examples
workflow should pass.
You can work on this issue either when #338 is resolved for the repo(s) you are maintaining, or work on both issues at the same time.
Preamble
Same as https://github.com/easystats/easystats/issues/338
Examples
Same as https://github.com/easystats/easystats/issues/338
Progress tracker
- [x] insight
- [ ] modelbased
- [ ] bayestestR
- [x] effectsize
- [x] parameters
- [x] performance
- [x] correlation
- [x] report
- [ ] see
- [x] datawizard
- [x] easystats
@IndrajeetPatil Why would this pass but suddenly fail when R-CMD-check-strict
was created?
https://github.com/easystats/effectsize/actions/workflows/check-all-examples.yaml
@mattansb It has actually nothing to do with the new strict check.
Previously, the “check all examples” workflow was checking only that all examples run. Now, it additionally checks that examples don’t produce warnings. That’s what the current issue is about.
Ahhhhh ok. Thanks!
@IndrajeetPatil Is it possible to ignore some warnings (without using suppressWarnings()
since we still want to show them to users)? In the following example, a warning is expected and I think it's useful to show the users the potential warnings:
https://github.com/easystats/datawizard/actions/runs/3918766334/jobs/6699343379
library(datawizard)
test <- data.frame(
a = c("iso", 2, 5),
b = c("year", 3, 6),
c = c(NA, 5, 7)
)
test
#> a b c
#> 1 iso year NA
#> 2 2 3 5
#> 3 5 6 7
row_to_colnames(test)
#> Warning: Some values of row 1 were NAs. The corresponding column names are
#> prefixed with `x`.
#> iso year x1
#> 2 2 3 5
#> 3 5 6 7
Hmm, I am wondering if it's really necessary to show an example that is going to generate a warning.
Typically, the help page examples will expose the functionality but not the edge cases users might run into, which is where they are likely to see warnings and errors. Does that make sense?
That said, if you do want to retain that example, maybe just set verbose = FALSE
?
Right, it doesn't bring much to show warnings in the example, I'll change the example
In examples I often see that we load the current package, but I've never seen that anywhere else before. Why do we do that? Should I remove those instances?
Yeah, I have also noticed this. It's definitely not necessary, but I don't feel strongly either way.
I think you can let them be for now. We do have a number of other, more immediate issues to resolve that we can prioritize.
In examples I often see that we load the current package, but I've never seen that anywhere else before. Why do we do that? Should I remove those instances?
Due to lazyness, I copy/paste examples into an R file, and then I don't need to load the related library manually.
No more warnings in examples for report
Some examples have warnings (and therefore this check fails) because of the environment problem due to insight
:
Could not recover model data from environment. Please make sure your data is available in your workspace. Trying to retrieve data from the model frame now.
This only happens in devtools::run_examples()
, not when I run them manually. Should we ignore them? Users shouldn't see these warnings and it might confuse them to add a data <<- data
in the examples (if this fixes the issue)