[英]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.