问题描述
在 Windows 上安装 Rcpp 包时,需要确保包 DLL 已卸载,否则在复制新 DLL 时会出现权限被拒绝"错误.这意味着在每次重新编译时都重新启动 R,这很烦人.有没有办法在不杀死R的情况下卸载包DLL?
When installing a Rcpp package on Windows, you need to ensure that the package DLL is unloaded or you get a "Permission Denied" error when copying the new DLL. This means restarting R on every recompile, which is pretty annoying. Is there any way to unload the package DLL without killing R?
我已经尝试了 detach("package:my_package", force=TRUE)
命令,但它没有卸载 DLL.
I've tried the detach("package:my_package", force=TRUE)
command, but it doesnt unload the DLL.
推荐答案
如果您想在主 R 会话中执行此操作(不使用 RStudio,这使得重新安装包和重新加载 R 变得非常容易),您可以使用 devtools:
If you want to do this in your main R session (without using RStudio, which makes reinstalling the package and reloading R very easy), you can use devtools:
library(devtools)
load_all("path/to/my/package")
除其他外,load_all
将重新加载您的所有 R 代码,并重新编译并重新附加 DLL.
Among other things, load_all
will reload all your R code, and re-compile and reattach the DLL.
这篇关于可以在不重启 R 的情况下卸载 Rcpp 包 DLL 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!