安卓手機上安裝linux 和R環(huán)境

環(huán)境:

  • 一臺舊安卓機
  • cpu 4核 armhf
  • 內(nèi)存2G
  • 互聯(lián)網(wǎng)

安裝流程

  1. 將安卓手機root (必須)
  1. 去應(yīng)用商店下載app linux deploy 應(yīng)用,安裝
  • 打開后,在右下角點擊下載應(yīng)用配置:

  • 發(fā)行版 : ubuntu

  • 架構(gòu): armhf

  • 源地址: 如果網(wǎng)速好可以選擇默認源,如果網(wǎng)速差建議去百度清華源或者網(wǎng)易源

  • 安裝路徑要選好;

  • 鏡像大?。?選擇2048M

  • 用戶名自定義

  • 密碼自定義

  • 勾選允許啟動SSH服務(wù) (默認端口22)

  • 不勾選允許圖形界面啟動

  1. 在depoly界面右上角選擇安裝,然后等待下載成功;
  1. 成功后選擇啟動系統(tǒng),此時界面上有系統(tǒng)的局域網(wǎng)ip地址;
  • 比如 192.168.1.10
  1. 在PC端使用ssh工具,比如xshell遠程連接設(shè)備(需要在同一個局域網(wǎng)下面)
  • 登錄
  • ssh 192.168.1.10
  1. 登錄后先安裝aptitude,然后安裝vim編輯器
sudo apt-get install aptitude 
sudo aptitude install vim
  1. 備份源文件并修改源列表,注意,該系統(tǒng)的源文件應(yīng)該是基于armhf架構(gòu)的


cp /etc/apt/sources.list source.list.bak

  • 然后修改源列表,此處我們選擇清華的源:
vim /etc/apt/soures.list

#填入以下內(nèi)容:



deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-proposed main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.ustc.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe


  • 完成后更新源列表:
sudo apt-get update

  1. vim 中文輸入亂碼解決:
#安裝locales
aptitude install locales
#配置locales
dpkg-reconfigure locales
#選擇以下幾種編碼

en_US.UTF8
zh_CN GB2312
zh_CN GBK GBK
zh_CN UTF-8 UTF-8

默認編碼選擇

zh_CN UTF-8 UTF-8

Generating locales (this might take a while)...
en_US.UTF-8... done
zh_CN.GB2312... done
zh_CN.GBK... done
zh_CN.UTF-8... done
Generation complete.

  1. 直接在線安裝R語言

sudo aptitude install r-base
  1. 安裝一些數(shù)據(jù)ETL的R包
install.packages(c("dplyr","stringr","data.table"),repos = "https://mirrors.eliteu.cn/CRAN/")



#install.packages("dplyr",repos = "https://mirrors.eliteu.cn/CRAN/")
  1. 安裝jdk8
sudo aptitude install   openjdk-8-jdk
sudo aptitude install  default-jre
#重新配置R語言java環(huán)境變量
sudo R CMD javareconf

  1. 安裝curl linux包
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libxml2-dev

  1. 安裝R爬蟲包

install.packages(c("RCurl","XML"),repos = "https://mirrors.eliteu.cn/CRAN/")


  1. R爬蟲包測試代碼:

library(stringr)
library(RCurl)
library(XML)
url <- paste("https://movie.douban.com/top250?start=",seq(0,225,by=25),"&filter=",sep = "")
y <- NULL;
country <- NULL
for (i in 1:length(url)){
  wp<-getURL(url[i],.encoding="gb2312",followlocation=T) 
  doc <- htmlParse(wp,asText=T,encoding="UTF-8")#解析
  #電影名字
  name <- xpathSApply(doc,path="http://span[@class='title'][1]",xmlValue)
  #評分
  score <- xpathSApply(doc,path="http://span[@class='rating_num' and @property='v:average']",xmlValue)
  #上映時間
  time <- str_extract(xpathSApply(doc,path="http://div[@class='bd']/p[@class='']",xmlValue),pattern = '[1-2][0-9]{3}')
  #生產(chǎn)地區(qū)
  for(j in 1:25){
    country[j] <- str_split(str_extract(xpathSApply(doc,path="http://div[@class='bd']/p[@class='']",xmlValue),pattern = '[1-2][0-9].*/.*/'),pattern = "/")[[j]][2]
  }
  country <- str_trim(country)
  x <- cbind(name,score,time,country)
  y <- rbind(y,x)
}
y <- as.data.frame(y)#存入數(shù)據(jù)框y





最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容