[英]Including caret in another package gives error during devtools::check() - “there is no package called 'lattice'”
I am trying to include caret in a package that I am developing.我正在尝试在我正在开发的 package 中包含插入符号。 When I run devtools::check(), I get an error "there is no package called 'lattice'".
当我运行 devtools::check() 时,我收到一个错误“没有名为 'lattice' 的 package”。 If I remove caret from the "Imports" section of the DESCRIPTION file, the error goes away.
如果我从说明文件的“导入”部分中删除插入符号,错误就会消失。 I am not sure what is causing this issue.
我不确定是什么导致了这个问题。 Lattice is installed on my machine.
格子安装在我的机器上。
I don't know how to provide a reproducible example since the package is in development so I have included a version of the package here .我不知道如何提供可重现的示例,因为 package 正在开发中,因此我在此处包含了 package 的版本。 If it helps, my DESCRIPTION file (without caret) looks like this
如果有帮助,我的说明文件(没有插入符号)看起来像这样
Package: tswgewrapped
Title: Helpful wrappers for 'tswge', 'vars' and 'nnfor' time series packages
Version: 1.8.10
Authors@R: c(
person("David", "Josephs", email = "josephsd@smu.edu", role = c("aut", "cre")),
person("Nikhil", "Gupta", email = "guptan@smu.edu", role = c("aut")))
Description: This package provides several helpful wrappers for the already useful 'tswge', 'vars' and 'nnfor' package. In the future, this package intends to move away from the tswge backend, to be faster, with more readable source code.
License: AGPL-3
Encoding: UTF-8
LazyData: true
Imports:
assertr,
doParallel,
dplyr,
ggfortify,
GGally,
ggplot2,
magrittr,
nnfor,
rlang,
pander,
parallel,
patchwork,
purrr,
R6,
RColorBrewer,
Rfast,
tibble,
tictoc,
tswge,
vars,
forecast
RoxygenNote: 7.1.0
Suggests:
testthat (>= 2.1.0),
tseries,
knitr,
rmarkdown
VignetteBuilder: knitr
Here is my sessionInfo这是我的会话信息
> sessionInfo()
R version 3.5.1 (2018-07-02)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows >= 8 x64 (build 9200)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tswgewrapped_1.8.10 caret_6.0-84 ggplot2_3.3.0 lattice_0.20-41
loaded via a namespace (and not attached):
[1] colorspace_1.4-1 class_7.3-15 rprojroot_1.3-2 fs_1.3.1 rstudioapi_0.10 roxygen2_7.1.0
[7] remotes_2.1.0 smooth_2.5.5 lubridate_1.7.4 prodlim_2018.04.18 xml2_1.2.0 splines_3.5.1
[13] codetools_0.2-16 doParallel_1.0.14 knitr_1.23 pkgload_1.0.2 greybox_0.5.8 nloptr_1.2.1
[19] compiler_3.5.1 tictoc_1.0 backports_1.1.4 assertthat_0.2.1 RcppZiggurat_0.1.5 Matrix_1.2-17
[25] strucchange_1.5-2 cli_1.1.0 prettyunits_1.0.2 tools_3.5.1 gtable_0.3.0 glue_1.3.1
[31] reshape2_1.4.3 dplyr_0.8.5 Rcpp_1.0.1 fracdiff_1.4-2 xopen_1.0.0 lamW_1.3.0
[37] urca_1.3-0 tswge_1.0.0 nlme_3.1-137 iterators_1.0.10 vars_1.5-3 lmtest_0.9-37
[43] timeDate_3043.102 gower_0.2.1 xfun_0.8 stringr_1.4.0 ps_1.3.0 testthat_2.1.1
[49] devtools_2.1.0 statmod_1.4.33 MASS_7.3-51.4 zoo_1.8-6 scales_1.0.0 ipred_0.9-9
[55] parallel_3.5.1 sandwich_2.5-1 RColorBrewer_1.1-2 yaml_2.2.0 quantmod_0.4-15 curl_3.3
[61] memoise_1.1.0 gridExtra_2.3 pander_0.6.3 rcmdcheck_1.3.3 rpart_4.1-15 reshape_0.8.8
[67] stringi_1.4.3 tseries_0.10-47 desc_1.2.0 foreach_1.4.4 TTR_0.23-4 pkgbuild_1.0.3
[73] lava_1.6.5 rlang_0.4.2 pkgconfig_2.0.2 purrr_0.3.3 nnfor_0.9.6 recipes_0.1.6
[79] patchwork_1.0.0 Rfast_1.9.9 processx_3.4.1 tidyselect_0.2.5 GGally_1.5.0 plyr_1.8.4
[85] magrittr_1.5 R6_2.4.0 generics_0.0.2 pillar_1.4.2 withr_2.1.2 xts_0.11-2
[91] survival_2.44-1.1 nnet_7.3-12 ggfortify_0.4.8 tibble_2.1.3 crayon_1.3.4 usethis_1.5.1
[97] grid_3.5.1 data.table_1.12.2 callr_3.3.1 ModelMetrics_1.2.2 forecast_8.9 digest_0.6.20
[103] MAPA_2.0.4 assertr_2.7 tidyr_0.8.3 numDeriv_2016.8-1.1 tsutils_0.9.2 stats4_3.5.1
[109] RcppParallel_4.4.3 munsell_0.5.0 sessioninfo_1.1.1 quadprog_1.5-7
I finally figured out the solution to my issue.我终于找到了解决我的问题的方法。
Solution 1解决方案 1
I had installed R on my new compute more than a year ago and hence was using version 3.5.1.一年多前,我在我的新计算机上安装了 R,因此使用的是 3.5.1 版本。 For some reason (you can see my my SessionInfo), caret and lattice were showing up under
other attached packages
and not under loaded via a namespace (and not attached)
.出于某种原因(你可以看到我的我的 SessionInfo),插入符号和格子出现在
other attached packages
下,而不是loaded via a namespace (and not attached)
。
I also noticed that if I place caret in the my package namespace, then the installation part of the devtools::check()
went though without any issue, but the process complained about lattice during the unit tests section.我还注意到,如果我将插入符号放在我的 package 命名空间中,那么
devtools::check()
的安装部分虽然没有任何问题,但是该过程在单元测试部分抱怨格子。
So the temporary solution that I found was to install lattice
and the forecast
packages in the unit test setup section (testthat.R).所以我找到的临时解决方案是在单元测试设置部分(testthat.R)中安装
lattice
和forecast
包。 This does not seem like a clean solution but it worked.这似乎不是一个干净的解决方案,但它确实有效。 You can see that here - version 1.8.10.8 of the package .
您可以在这里看到 - package 的 1.8.10.8 版本。
if(!require("lattice")){
# https://github.com/topepo/caret/issues/411#issuecomment-209973908
install.packages("lattice", repos = "http://cran.us.r-project.org", dependencies = c("Depends", "Imports", "Suggests"))
}
if(!require("forecast")){
# https://github.com/topepo/caret/issues/411#issuecomment-209973908
install.packages("forecast", repos = "http://cran.us.r-project.org", dependencies = c("Depends", "Imports", "Suggests"))
}
Solution 2解决方案 2
Yesterday, I upgraded to the latest version of R (3.6.3) and installed all the packages again.昨天,我升级到最新版本的R(3.6.3)并重新安装了所有的包。 Now you can see from my SessionInfo that
caret
and lattice
correctly show up under the loaded via a namespace (and not attached)
section.现在您可以从我的 SessionInfo 中看到
caret
和lattice
正确显示在loaded via a namespace (and not attached)
下方。
And now, everything works fine with devtools::check()
even if I remove the lattice
and forecast
package installation from the unit test setup section.现在,即使我从单元测试设置部分删除
lattice
并forecast
package 安装, devtools::check()
一切正常。 So I believe there was some issue with the older version of R and how it was interacting with my setup.所以我相信旧版本的 R 以及它如何与我的设置交互存在一些问题。
> sessionInfo()
R version 3.6.3 (2020-02-29)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 17763)
Matrix products: default
Random number generation:
RNG: Mersenne-Twister
Normal: Inversion
Sample: Rounding
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252 LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] tswgewrapped_1.8.10.9
loaded via a namespace (and not attached):
[1] colorspace_1.4-1 ellipsis_0.3.0 class_7.3-15 rprojroot_1.3-2 fs_1.4.1 rstudioapi_0.11
[7] roxygen2_7.1.0 remotes_2.1.1 smooth_2.5.6 prodlim_2019.11.13 fansi_0.4.1 lubridate_1.7.8
[13] xml2_1.3.1 codetools_0.2-16 splines_3.6.3 doParallel_1.0.15 knitr_1.28 pkgload_1.0.2
[19] greybox_0.5.9 nloptr_1.2.2.1 pROC_1.16.2 caret_6.0-86 compiler_3.6.3 tictoc_1.0
[25] backports_1.1.6 assertthat_0.2.1 RcppZiggurat_0.1.5 Matrix_1.2-18 strucchange_1.5-2 cli_2.0.2
[31] prettyunits_1.1.1 tools_3.6.3 gtable_0.3.0 glue_1.4.0 reshape2_1.4.4 dplyr_0.8.5
[37] Rcpp_1.0.4.6 xopen_1.0.0 fracdiff_1.5-1 vctrs_0.2.4 lamW_1.3.0 urca_1.3-0
[43] tswge_1.0.0 nlme_3.1-144 iterators_1.0.12 vars_1.5-3 lmtest_0.9-37 timeDate_3043.102
[49] gower_0.2.1 xfun_0.13 stringr_1.4.0 ps_1.3.2 testthat_2.3.2 lifecycle_0.2.0
[55] devtools_2.3.0 statmod_1.4.34 MASS_7.3-51.5 zoo_1.8-7 scales_1.1.0 ipred_0.9-9
[61] parallel_3.6.3 sandwich_2.5-1 RColorBrewer_1.1-2 quantmod_0.4.17 curl_4.3 memoise_1.1.0
[67] gridExtra_2.3 ggplot2_3.3.0 pander_0.6.3 rcmdcheck_1.3.3 rpart_4.1-15 reshape_0.8.8
[73] stringi_1.4.6 tseries_0.10-47 desc_1.2.0 foreach_1.5.0 TTR_0.23-6 pkgbuild_1.0.6
[79] lava_1.6.7 rlang_0.4.5 pkgconfig_2.0.3 pracma_2.2.9 lattice_0.20-38 purrr_0.3.4
[85] nnfor_0.9.6 recipes_0.1.10 patchwork_1.0.0 Rfast_1.9.9 processx_3.4.2 tidyselect_1.0.0
[91] GGally_1.5.0 plyr_1.8.6 magrittr_1.5 R6_2.4.1 generics_0.0.2 pillar_1.4.3
[97] withr_2.1.2 xts_0.12-0 survival_3.1-8 nnet_7.3-12 ggfortify_0.4.9 tibble_3.0.0
[103] crayon_1.3.4 usethis_1.6.0 grid_3.6.3 data.table_1.12.8 callr_3.4.3 ModelMetrics_1.2.2.2
[109] forecast_8.12 digest_0.6.25 MAPA_2.0.4 assertr_2.7 tidyr_1.0.2 tsutils_0.9.2
[115] RcppParallel_5.0.0 stats4_3.6.3 munsell_0.5.0 sessioninfo_1.1.1 quadprog_1.5-8
I hope this will be helpful for future readers.我希望这对未来的读者有所帮助。 Lesson learned is to not be too out of sync with the latest version of the tool and packages .
吸取的教训是不要与最新版本的工具和软件包太不同步。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.