move spData to Suggests:
edzer opened this issue · comments
It looks like classInt checks fine if
- spData is moved from Depends: to Suggests, and
- import(spData) is removed from NAMESPACE
since spData is not needed for the functions of classInt, I'd suggest doing this.
In classInt, I'm moving **spData ** from Depends: to Suggests:. However, when the example code is in an if/else block, the output does not appear in the correct order in relation to the code. This completely mangles the pkgdown output introduced last week. How should I tell pkgdown to interleave the example output inside the if/else block? @edzer and r-spatial/sf#922
Did this happen only after moving the dependency? Which example does this concern?
Because all the examples now use:
if (!require("spData", quietly=TRUE)) {
message("spData package needed for examples")
} else {
data(jenks71, package="spData")
<do stuff>
}
the example as run by pkgdown::build_site()
runs and prints the whole block, then outputs the figures and results after block completion. That is normal behaviour, and is seen everywhere else. However, only pkgdown displays the output, regular help does nor, and invites copy&paste. Since more packages got shifted to Suggests:, this is a more general problem.
I'm doing the revdep checks for classInt with spData installed, and once done will remove spData and re-run to see whether anything breaks.
An example pkgdown example output element for findColours()
if (!require("spData", quietly=TRUE)) {
message("spData package needed for examples")
} else {
data(jenks71, package="spData")
mypal <- c("wheat1", "red3")
h5 <- classIntervals(jenks71$jenks71, n=5, style="hclust", method="complete")
print(findColours(h5, mypal))
print(findColours(getHclustClassIntervals(h5, k=7), mypal))
h5Colours <- findColours(h5, mypal)
plot(h5, mypal, main="Complete hierarchical clustering")
legend(c(95, 155), c(0.12, 0.4), fill=attr(h5Colours, "palette"),
legend=names(attr(h5Colours, "table")), bg="white")
h5tab <- attr(h5Colours, "table")
legtext <- paste(names(h5tab), " (", h5tab, ")", sep="")
plot(h5, mypal, main="Complete hierarchical clustering (with counts)")
legend(c(95, 165), c(0.12, 0.4), fill=attr(h5Colours, "palette"),
legend=legtext, bg="white")
}
#> [1] "#FFE7BA" "#E6735D" "#E6735D" "#F2AD8B" "#E6735D" "#E6735D" "#E6735D"
#> [8] "#E6735D" "#D9392E" "#CD0000" "#D9392E" "#D9392E" "#E6735D" "#E6735D"
#> [15] "#F2AD8B" "#E6735D" "#E6735D" "#E6735D" "#E6735D" "#D9392E" "#F2AD8B"
#> [22] "#E6735D" "#F2AD8B" "#F2AD8B" "#E6735D" "#F2AD8B" "#F2AD8B" "#F2AD8B"
#> [29] "#F2AD8B" "#E6735D" "#F2AD8B" "#FFE7BA" "#F2AD8B" "#F2AD8B" "#F2AD8B"
#> [36] "#F2AD8B" "#FFE7BA" "#FFE7BA" "#F2AD8B" "#F2AD8B" "#FFE7BA" "#F2AD8B"
#> [43] "#F2AD8B" "#FFE7BA" "#F2AD8B" "#F2AD8B" "#FFE7BA" "#F2AD8B" "#FFE7BA"
#> [50] "#FFE7BA" "#F2AD8B" "#F2AD8B" "#FFE7BA" "#F2AD8B" "#F2AD8B" "#FFE7BA"
#> [57] "#F2AD8B" "#F2AD8B" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> [64] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> [71] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> [78] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> [85] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> [92] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> [99] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#FFE7BA"
#> attr(,"palette")
#> [1] "#FFE7BA" "#F2AD8B" "#E6735D" "#D9392E" "#CD0000"
#> attr(,"table")
#> [15.57,54.81) [54.81,74.405) [74.405,105.95) [105.95,143.4) [143.4,155.3]
#> 55 27 15 4 1
#> [1] "#F6C09B" "#E6735D" "#E6735D" "#EE9A7C" "#E6735D" "#E6735D" "#E6735D"
#> [8] "#DD4D3E" "#D5261F" "#CD0000" "#D5261F" "#D5261F" "#DD4D3E" "#E6735D"
#> [15] "#EE9A7C" "#DD4D3E" "#E6735D" "#E6735D" "#E6735D" "#D5261F" "#EE9A7C"
#> [22] "#E6735D" "#EE9A7C" "#EE9A7C" "#E6735D" "#EE9A7C" "#EE9A7C" "#EE9A7C"
#> [29] "#EE9A7C" "#DD4D3E" "#EE9A7C" "#F6C09B" "#EE9A7C" "#EE9A7C" "#EE9A7C"
#> [36] "#EE9A7C" "#F6C09B" "#F6C09B" "#EE9A7C" "#EE9A7C" "#F6C09B" "#EE9A7C"
#> [43] "#EE9A7C" "#F6C09B" "#EE9A7C" "#EE9A7C" "#F6C09B" "#EE9A7C" "#F6C09B"
#> [50] "#F6C09B" "#EE9A7C" "#EE9A7C" "#F6C09B" "#EE9A7C" "#EE9A7C" "#F6C09B"
#> [57] "#EE9A7C" "#EE9A7C" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B"
#> [64] "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B"
#> [71] "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B"
#> [78] "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B" "#F6C09B"
#> [85] "#F6C09B" "#F6C09B" "#F6C09B" "#FFE7BA" "#F6C09B" "#FFE7BA" "#FFE7BA"
#> [92] "#F6C09B" "#F6C09B" "#FFE7BA" "#FFE7BA" "#FFE7BA" "#F6C09B" "#FFE7BA"
#> [99] "#FFE7BA" "#FFE7BA" "#FFE7BA" "#F6C09B"
#> attr(,"palette")
#> [1] "#FFE7BA" "#F6C09B" "#EE9A7C" "#E6735D" "#DD4D3E" "#D5261F" "#CD0000"
#> attr(,"table")
#> [15.57,29.84) [29.84,54.81) [54.81,74.405) [74.405,90.16) [90.16,105.95)
#> 10 45 27 11 4
#> [105.95,143.4) [143.4,155.3]
#> 4 1
followed by the figures.
What about leaving out the if
blocks?
> data(jenks71, package="spDataxx")
Error in find.package(package, lib.loc, verbose = verbose) :
there is no package called ‘spDataxx’
and R CMD check doesn't complain... do users still need to be reminded that if a package is not there, they need to install it?
How does R CMD check not complain?
Aha, you mean not even put spDataxx in Suggests:?
No, spData
would be in Suggests: .
Of course R CMD check complains if spData is not there, but that is not a problem. You check with spData in place, and so does CRAN, and users see the regular error message I showed above when they try to run examples that load data from spData.
There is no need for if
blocks in examples that check for spData presence.
But CRAN has _R_CHECK_FORCE_SUGGESTS_
for a purpose, and has used it. Default is TRUE
, but with FALSE
, the check will fail on these examples if not protected by if
blocks. I've inserted run <- TRUE
or FALSE
depending on spData availability, to split up the example output in fine-grained if (run) {
blocks. The environment variable is to permit shorter runtimes for checks, I think.
My impression was that if R CMD check --as-cran pkg
checks clean, you are fine. It does without the if blocks.
Yes, but that doesn't double-check or help CRAN. CRAN policy says:
A package listed in ‘Suggests’ or ‘Enhances’ should be used conditionally in examples or tests if it cannot straightforwardly be installed on the major R platforms.
which is your position. I recall clearly being asked to check packages with _R_CHECK_FORCE_SUGGESTS_
set FALSE
as a safeguard in 2012 (emails in April, August and November) - I think it involved an sp release and revdep tests. I always run revdep tests under _R_CHECK_FORCE_SUGGESTS_=FALSE
to save time (but get false positives when packages do not test for the availability of Suggests: packages). So I will continue to use if
blocks to possibly make life easier for others running revdep checks.
Fair enough!
... and thanks to @angela-li for nudging me into this century!
Submitted 0.3-1 to CRAN.
classInt 0.3-1 on CRAN.