简体   繁体   English

R CMD检查失败,devtools :: test()工作正常

[英]R CMD check fails, devtools::test() works fine

Sometimes R CMD check fails when all your test run fine when you run the manually (or using devtools::test()). 当您手动运行(或使用devtools :: test())时,所有测试运行正常时,R CMD检查有时会失败。

I ran into one of such issues as well, when I wanted to compare results from bootstrapping using the boot package. 当我想使用启动包比较bootstrapping的结果时,我遇到了其中一个问题。 I went into a rabbit hole looking for issues caused by parallel computation (done by boot) and Random Number Generators (RNGs). 我进入了一个兔子洞,寻找由并行计算(由引导完成)和随机数生成器(RNG)引起的问题。

These were all not the answers. 这些都不是答案。

In the end, the issue was trivial. 最后,问题是微不足道的。 I used base::sort() to create the levels of a factor. 我使用base :: sort()来创建一个因子的级别。 (To ensure that they would always align, even if the data was in a different order) (确保它们始终对齐,即使数据的顺序不同)

The problem is, that the default sort method depends on the locale of your system. 问题是,默认排序方法取决于系统的区域设置。 And R CMD check uses a different locale than my interactive session. 并且R CMD检查使用与我的交互式会话不同的区域设置。

The issue resided in this: R interactively used:LC_COLLATE=en_US.UTF-8; 问题在于:R交互使用:LC_COLLATE = en_US.UTF-8; R CMD check used: LC_COLLATE=C; 使用R CMD检查:LC_COLLATE = C;

In the details of base::sort this is mentioned: 在base :: sort的细节中提到:

Except for method ‘"radix"’, the sort order for character vectors
will depend on the collating sequence of the locale in use: 
see ‘Comparison’.  The sort order for factors is the order of their 
levels (which is particularly appropriate for ordered factors).

I now resolved the issue by specifying the radix sort method. 我现在通过指定基数排序方法解决了这个问题。

Now, all works fine. 现在,一切正常。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 "testthat 在 devtools::check 中失败,但在 devtools::test 中有效" - testthat fails within devtools::check but works in devtools::test 使用 lintr::expect_lint_free() 进行测试失败并使用 devtools::check() 但可以使用 devtools::test() - testthat with lintr::expect_lint_free() fails with devtools::check() but works with devtools::test() devtools::test() 有效,但 devtools::check() 在测试 `expect_known_value()` 时失败 - devtools::test() works, but devtools::check() fails when testing `expect_known_value()` R CMD检查失败 - R CMD Check fails “R CMD check”在使用“devtools::test()”时抛出警告,但允许“test()”,但需要使用完整的 function 名称 - “R CMD check” throws warning on use of 'devtools::test()', but allows 'test()', but need to use full function name lintr测试使用devtools :: check()传递,并使用devtools :: test()失败 - lintr test passes with devtools::check() and fails with devtools::test() r devtools::test 失败但所有上下文都正常 - r devtools::test fails but all contexts are OK devtools :: test()有效,但devtools :: check()没有。 为什么? - devtools::test() works but devtools::check() doesn't. Why? R CMD check (devtools:check()) with keep.source = TRUE 可能吗? - Is R CMD check (devtools:check()) with keep.source = TRUE possible? R CMD check fails with ubuntu when trying to download file, but function works within R - R CMD check fails with ubuntu when trying to download file, but function works within R
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM