安装R包时,遇到如下的权限错误问题:

txt
1R> install.package("xml2")
2...
3** checking absolute paths in shared objects and dynamic libraries
4mv: cannot move '/home/yanll/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-xml2/00new/xml2' to '/home/yanll/R
5/x86_64-pc-linux-gnu-library/4.1/xml2': Permission denied
6ERROR:   moving to final location failed
7...

解决方法是:

txt
1R> install.packages("xml2", dependencies=TRUE, INSTALL_opts = c('--no-lock'))

参考:https://askubuntu.com/questions/1163130/permission-denied-while-installing-r-package