首先按照官網(wǎng)上的代碼進(jìn)行安裝
devtools::install_github('cole-trapnell-lab/leidenbase')
devtools::install_github('cole-trapnell-lab/monocle3')
在最后一步安裝運(yùn)行以上兩行代碼時出現(xiàn)了問題:
checking udunits2.h usability... no
checking udunits2.h presence... no
checking for udunits2.h... no
checking udunits2/udunits2.h usability... no
checking udunits2/udunits2.h presence... no
checking for udunits2/udunits2.h... no
checking for ut_read_xml in -ludunits2... no
configure: error: in `/tmp/RtmphiMa1k/R.INSTALL23ef48d1156/units':
configure: error:
使用yum在CentOS7上運(yùn)行:
sudo yum install udunits2-devel
仍然報錯:
沒有可用軟件包 udunits2-devel娩怎。
yum沒有找到對應(yīng)依賴包笑旺,更新epel第三方軟件庫眉睹,運(yùn)行命令:
yum install -y epel-release
然后再在terminal和R中分別執(zhí)行以下兩行代碼就可以了:
sudo yum install udunits2-devel
install.packages(units)
繼續(xù)安裝monocle3,又報錯:
* installing *source* package ‘sf’ ...
** package ‘sf’ successfully unpacked and MD5 sums checked
** using staged installation
configure: CC: gcc -std=gnu99
configure: CXX: g++ -std=gnu++11
checking for gdal-config... no
no
configure: error: gdal-config not found or not executable.
ERROR: configuration failed for package ‘sf’
* removing ‘/local/txm/R/x86_64-pc-linux-gnu-library/4.0/sf’
Warning in install.packages :
installation of package ‘sf’ had non-zero exit status
提示sf包安裝失敗播聪,原因是gdal沒有安裝椒振,在terminal里面執(zhí)行
sudo yum install gdal gdal-devel
發(fā)現(xiàn)yum最高只能安裝1.11.4的gdal昭伸,于是嘗試手動安裝,參考以下博客:http://www.reibang.com/p/3173513d16a5
geos澎迎,proj等包的安裝都比較順利庐杨,唯獨(dú)gdal要么是裝不上选调,要么是裝上之后sf還是無法安裝,折騰這玩意兒花了勞資3天的時間灵份,參考了無數(shù)博客仁堪,最后成功的代碼如下:
# 在terminal里安裝gdal2.4.4
tar -zxvf gdal-2.4.4.tar.gz
cd gdal-2.4.4
./configure --with-gdal-ver=T --prefix=/usr/local --with-geos=/usr/local/bin # 將軟件安裝在/usr/local
make
sudo make install
ldconfig
/usr/local/bin/gdalinfo --version # GDAL 2.4.4, released 2020/01/08 表明安裝成功
# 設(shè)置環(huán)境變量PKG_CONFIG_PATH
vi ~/.bash_profile
# 在末尾添加下面兩行:
PKG_CONFIG_PATH=/usr/lib/pkgconfig:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
# 最后重啟bash,讓環(huán)境變量生效:
source ~/.bash_profile
最后填渠,在R中安裝sf包和monocle3
install.packages("sf", configure.args = "--with-gdal-config=/usr/local/bin/gdal-config --with-proj-include=/usr/local/include/ --with-proj-lib=/usr/local/lib/")
library(devtools)
devtools::install_github('cole-trapnell-lab/monocle3')
參考
https://stackoverflow.com/questions/50362201/udunits2-r-install-udunits2-h-not-found
https://blog.csdn.net/qq_46480020/article/details/111940512
https://www.omicsclass.com/article/1349
https://github.com/r-spatial/sf/issues/1158