当前位置:主页 > 技术文档 > Ubuntu 下载

Ubuntu20安装R编程语言 高清版

  • 更新:2020-10-10 08:07:05
  • 大小:904 KB
  • 热度:508
  • 审核:衡秀梅
  • 类别:技术文章
  • 格式:PDF

  • 资源介绍
  • 学习心得
  • 相关内容

R语言环境变量的设置

环境设置函数为options(),用options()命令可以设置一些环境变量,使用help(options)可以查看详细的参数信息。

1. 数字位数的设置,options(digits=n),n一般默认情况下是7位,但实际上的范围是1~22,可以随意设置位数。

#这个命令,可以把R的整数表示能力设为10位。
options(digits=10)

2. 扩展包的安装,使用下面的命令,可以联网安装扩展包。

options(CRAN="http://cran.r-project.org") 
install.packages("扩展包名")

3. 利用R里的options函数进行光标和数字位数设置。

用R写代码时,打字水平不高,有时候不知道乱按了一些键(现在我还不知道哪个键),光标就变成了加粗的竖直线,又改不回去。这种情况下我们可以用options函数进行光标设置,例如:

##可以随意设置你的光标类型(prompt参数设置)。
##光标开始默认为  >
options(prompt="|")
##光标为  |
options(prompt=">")
##光标为  >
options(prompt="|")
##光标为  |
options(prompt="+")
##光标为  +
options(prompt="-")
##光标为  -
options(prompt="8")
##光标为  8
options(prompt=">")  
##光标设置为开始默认值 >

4. R里的options函数进行错误信息显示(忽略)设置。

#这个命令,可以忽视任何警告
options(warn=-1) 
#这个命令,不放过任何警告
options(warn=1)

#示例展示
ow <- options("warn")
for(w in -1:1) {
  options(warn = w); cat("\n warn =", w, "\n")
  for(i in 1:4) { cat(i,"..\n"); m <- matrix(1:7, 3,4) }
}
warnings()
options(ow) # reset
tail(warnings(), 2)
#说明:
warn:
sets the handling of warning messages. If warn is negative all warnings are ignored. If warn is zero (the default) warnings are stored until the top–level function returns. If 10 or fewer warnings were signalled they will be printed otherwise a message saying how many were signalled. An object called last.warning is created and can be printed through the function warnings. If warn is one, warnings are printed as they occur. If warn is two or larger all warnings are turned into errors.
-------
警告:
设置警告消息的处理。如果警告是负面的,所有的警告都会被忽略。如果警告是零(默认)警告被存储到顶部,级别的函数返回。如果10个或更少的警告信号,他们将被打印出来,否则一个消息说有多少人发出信号。一个对象称为last.warning可以通过打印功能warnings。如果警告是一个,警告是印刷的,因为它们发生。如果警告是2或更大的所有警告被变成错误。

##还可以width来调整向量,矩阵的输出宽度,还包括是否用warnning来显示错误信息(show.error.messages)以及错误信息的长度(warning.length)。
options(show.error.locations = TRUE)
options("show.error.messages")

5. options()常用于设置R控制台、R语言计算相关的属性,常用属性名称及默认值如下:

add.smooth TRUE
check.bounds FALSE
continue "+ "
digits 7
echo TRUE
encoding "native.enc"
error NULL
expressions 5000
keep.source interactive()
keep.source.pkgs FALSE
max.print 99999
OutDec "."
prompt "> "
scipen 0
show.error.messages TRUE
timeout 60
verbose FALSE
warn 0
warning.length 1000
width 80
#装载不同的扩展包还会增加一些新的属性信息

 

资源获取

资源地址1:https://pan.baidu.com/s/1xTXPvuzsGSB27WjMFfnY4Q

相关资源

网友留言

Ubuntu 16.04 安装R和RStudio
向永福

在Ubuntu上安装R和Rstudio的时候碰到了一些依赖项不存在的错误

The following packages have unmet dependencies:
r-base-core : Depends: libc6 (>= 2.27) but 2.23-0ubuntu10 is to be installed
Depends: libcurl4 (>= 7.28.0) but it is not installable
Depends: libicu60 (>= 60.1-1~) but it is not installable
Depends: liblapack3 but it is not going to be installed or
liblapack.so.3
Depends: libreadline7 (>= 6.0) but it is not installable
Recommends: r-recommended but it is not going to be installed
Recommends: r-base-dev but it is not going to be installed
E: Unable to correct problems,you have held broken packages.

看着像依赖项冲突

apt命令其实不能很好处理冲突的情况,最好使用aptitude

sudo apt-get install aptitude

sudo aptitude install r-base

会提示哪些包出现来冲突

nstalled.
libicu-dev : Depends: libicu55 (= 55.1-7) but 55.1-7ubuntu0.4 is installed.
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) gfortran [Not Installed]
2) gfortran-5 [Not Installed]
3) libblas-dev [Not Installed]
4) libgfortran-5-dev [Not Installed]
5) libgfortran3 [Not Installed]
6) libicu-dev [Not Installed]
7) libjpeg-dev [Not Installed]
8) libjpeg-turbo8-dev [Not Installed]
9) libjpeg8-dev [Not Installed]
10) liblapack-dev [Not Installed]
11) liblapack3 [Not Installed]
12) libpng12-dev [Not Installed]
13) r-base [Not Installed]

,以及有哪些方案

Accept this solution? [Y/n/q/?] .
The following actions will resolve these dependencies:

Keep the following packages at their current version:
1) libjpeg-dev [Not Installed]
2) libjpeg-turbo8-dev [Not Installed]
3) libjpeg8-dev [Not Installed]
4) r-base-dev [Not Installed]

Downgrade the following packages:
5) cpp-5 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
6) g++-5 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
7) gcc-5 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
8) gcc-5-base [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
9) libasan2 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
10) libatomic1 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
11) libcc1-0 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
12) libcilkrts5 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
13) libgcc-5-dev [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
14) libgomp1 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
15) libicu55 [55.1-7ubuntu0.4 (now) -> 55.1-7 (xenial)]
16) libitm1 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
17) liblsan0 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
18) libmpx0 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
19) libpng12-0 [1.2.54-1ubuntu1.1 (now) -> 1.2.54-1ubuntu1 (xenial)]
20) libquadmath0 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
21) libstdc++-5-dev [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenia
22) libstdc++6 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
23) libtsan0 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]
24) libubsan0 [5.4.0-6ubuntu1~16.04.10 (now) -> 5.3.1-14ubuntu2 (xenial)]

Leave the following dependencies unresolved:

25) r-base-core recommends r-base-dev

解决冲突后即可安装成功

在shell里输入R,提示成功

R version 3.4.4 (2018-03-15) -- "Someone to Lean On"Copyright (C) 2018 The R Foundation for Statistical ComputingPlatform: x86_64-pc-linux-gnu (64-bit)

总结

以上是编程之家为你收集整理的Ubuntu 16.04 安装R和RStudio全部内容,希望文章能够帮你解决Ubuntu 16.04 安装R和RStudio所遇到的程序开发问题。

Ubuntu下安装R语言
弘子安

笔者是计算机小白,傻瓜式安装的软件很多都不会安装,操作系统也是宿舍大佬装上的。好了,废话不多说,试着在Ubuntu下安装R吧。。。

step 1

我想的是先从官网上下载关于R和Rstudio的Linux安装包

https://www.r-project.org/这就是R官网,怎么样,长得是不是很一般啊。

点击 download R 进入下载界面

选择镜像,说实话我不知道镜像是什么玩意儿,我选择的是China下列的https://mirrors.ustc.edu.cn/CRAN/中科大镜像,不知道你们选择什么样的

选择Download R for Linux就是了

进入发现又是一列选择,看样子是不同linux版本下的R安装不一样。不管了,选择Ubuntu的就行了,因为我的linux是Ubuntu

我擦,这么多选项,那tm怎么选啊。仔细阅读README文件内容好像说不同Ubuntu下载R方式不一样,我的Ubuntu是16.04,下载Xenial Xerus的

再阅读README好像说在*/etc/apt/sources.list* 这个路径下的这个文件最后面加上一种语句,我用的是中科大镜像,所以加上的是这样的 deb https://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu xenial/ 就是这么一句话,添加在sources.list文件的最后一行
安装呗,打开终端输入sudo apt-get update语句,估计是对安装文件sources.list的一个更新吧,因为我们前面添加了地址啊

然后在终端再输入sudo apt-get install r-base发现一大堆东西,应该是在安装了

终端输入sudo apt-get install r-base-dev不晓得说的是什么,好像是说对需要从源代码处编译R包的用户有用,咱也不懂,按他说的就是呗

README文件后面又说什么乱七八糟的但是我记着都是may之类的可有可无的,故不理睬,至此安装结束

step2

看看咱装的R咋样呗,终端输入R

安装成功了,哈哈哈哈哈哈哈哈哈哈哈哈哈。

wc,不对啊,这版本太低了。哎呀,deb https://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu xenial/应该是deb https://mirrors.ustc.edu.cn/CRAN/bin/linux/ubuntu xenial-cran35/才对。啊啊啊,再来一次吧。

wc,需要修改sources.list文件,不会了,哭泣,呜呜呜。。。算了,3.2就3.2吧。

装Rstudio吧,https://www.rstudio.com/products/rstudio/download/就从这里下载RStudio。deb格式下载到本地了。

终端输入sudo apt-get install gdebi-core应该是下载一种安装工具吧

终端输入sudo gdebi -n rstudio-1.2.1335-amd64.deb后面表示我下载到本地的RStudio版本,注意将路径改成安装包所在的相对路径

又经过一系列看不懂的安装过程后终于完毕了。在Application中搜索RStudio就发现已经装上了,哈哈哈哈哈哈哈

然后我又按照自己习惯改一下界面,是不是很好看啊