1.安裝R
在 /etc/apt/sources中添加源
sudo vim /etc/apt/sources.list
在sources.list文件的最后一行為系統(tǒng)添加相應(yīng)的鏡像源
#(19.04)
deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/
# (18.10)
deb https://cloud.r-project.org/bin/linux/ubuntu cosmic-cran35/
#(18.04;LTS)
deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/
#(16.04; LTS)
deb https://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/
#(14.04; LTS)
deb https://cloud.r-project.org/bin/linux/ubuntu trusty-cran35/
更新軟件源列表
sudo apt-get update
執(zhí)行如下命令安裝R語(yǔ)言:
sudo apt-get install r-base
系統(tǒng)會(huì)提示“您希望繼續(xù)執(zhí)行嗎? [y/n]" ,可以直接從鍵盤(pán)輸人y,然后按Enter鍵就可以了娇斩。只要遇到提問(wèn),都在鍵盤(pán)輸人y后按Enter鍵即可胶逢。
舊版本的R安裝時(shí)屏幕會(huì)顯示“--在此連線階段時(shí)請(qǐng)選用CRAN的鏡子--”,并彈出一個(gè)白色背景的豎條形窗口,窗口標(biāo)題是HTTPS CRAN mirros,標(biāo)題下面列出了很多國(guó)家的鏡像列表,可以選擇位于China的鏡像,例如谎仲,選擇China( Bejing)[https],然后單擊OK按鈕,就可以開(kāi)始安裝舞吭。新版本的不會(huì)顯示幔虏,可能是新版本默認(rèn)設(shè)置為外國(guó)版本(我用的3.6.3版本的是這樣)。安裝過(guò)程需要幾分鐘時(shí)間捂掰,當(dāng)然,安裝過(guò)程所需時(shí)間,也和當(dāng)前網(wǎng)絡(luò)速度有關(guān)系敢会。安裝結(jié)束后,輸入“R”啟動(dòng)R。
2.安裝依賴庫(kù)
為了完成可視化分析功能尘颓,需要為R安裝一些依賴庫(kù),包括RMySQL走触、ggplot2、devtools和recharts疤苹。啟動(dòng)R進(jìn)人R命令提示符狀態(tài),執(zhí)行如下命令安裝RMySQL:
> install.packages('RMySQL')
安裝可能會(huì)出現(xiàn)以下錯(cuò)誤:
Configure could not find suitable mysql/mariadb client library. Try installing:
* deb: libmariadbclient-dev | libmariadb-client-lgpl-dev (Debian, Ubuntu)
* rpm: mariadb-connector-c-devel | mariadb-devel | mysql-devel (Fedora, CentOS, RHEL)
* csw: mysql56_dev (Solaris)
* brew: mariadb-connector-c (OSX)
If you already have a mysql client library installed, verify that either
mariadb_config or mysql_config is on your PATH. If these are unavailable
you can also set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
如下圖所示:
我們需要安裝所欠缺的組件互广,也就是*deb:(紅色橫線)后面所顯示的組件。執(zhí)行下面命令安裝:
sudo apt-get install libmariadb-client-lgpl-dev
然后再重新執(zhí)行如下命令安裝RMySQL:
> install.packages('RMySQL')
執(zhí)行如下命令安裝繪圖包ggplot2:
> install.packages('ggplot2')
接下來(lái)繼續(xù)運(yùn)行下面命令安裝devtools:
> install.packages('devtools')
安裝時(shí)可能也會(huì)出現(xiàn)類(lèi)似的錯(cuò)誤:
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl@1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
--------------------------------------------------------------------
ERROR: configuration failed for package ‘openssl’
Configuration failed because libxml-2.0 was not found. Try installing:
* deb: libxml2-dev (Debian, Ubuntu, etc)
* rpm: libxml2-devel (Fedora, CentOS, RHEL)
* csw: libxml2_dev (Solaris)
If libxml-2.0 is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a libxml-2.0.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
如下圖:
同樣的卧土,我們安裝*deb后面所缺少的組件即可凸椿,可能需要安裝以下四個(gè)組件:
sudo apt-get install libssl-dev
sudo apt-get install libssh2-1-dev
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libxml2-dev
最后在R命令提示符下,再執(zhí)行如下命令安裝taiyun/ recharts :
> devtools::install_github('taiyun/recharts')
是的娄昆,還是會(huì)可能出現(xiàn)錯(cuò)誤:
> devtools::install_github('taiyun/recharts')
錯(cuò)誤: Failed to install 'unknown package' from GitHub:
Failed to connect to api.github.com port 443: 拒絕連接
安裝R時(shí)我們說(shuō)到新版本的R可能是默認(rèn)使用外國(guó)的鏡像隘庄,我們只需使用以下命令設(shè)置CRAN使用清華大學(xué)鏡像即可:
options(repos=structure(c(CRAN="https://mirrors.tuna.tsinghua.edu.cn/CRAN/")))
接著重新安裝taiyun/ recharts :
> devtools::install_github('taiyun/recharts')
至此囤官,R可視化分析的安裝工作完成。
參考鏈接:https://blog.csdn.net/m0_37601622/article/details/93135920
https://blog.csdn.net/qq_41858657/article/details/104707330
————————————————
版權(quán)聲明:本文為CSDN博主「Wingkin-」的原創(chuàng)文章颤霎,遵循CC 4.0 BY-SA版權(quán)協(xié)議媳谁,轉(zhuǎn)載請(qǐng)附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/Wing_kin666/article/details/106020600