r语言怎么将.rda文件传递给服务器

Python031

r语言怎么将.rda文件传递给服务器,第1张

JAVA 遍历文件夹下的所有文件(递归调用和非递归调用)

1.不使用递归的方法调用。

public void traverseFolder1(String path) {

int fileNum = 0, folderNum = 0

File file = new File(path)

if (file.exists()) {

LinkedList list = new LinkedList()

File[] files = file.listFiles()

for (File file2 : files) {

if (file2.isDirectory()) {

System.out.println("文件夹:" + file2.getAbsolutePath())

list.add(file2)

fileNum++

} else {

System.out.println("文件:" + file2.getAbsolutePath())

folderNum++

}

}

File temp_file

while (!list.isEmpty()) {

temp_file = list.removeFirst()

files = temp_file.listFiles()

for (File file2 : files) {

if (file2.isDirectory()) {

System.out.println("文件夹:" + file2.getAbsolutePath())

list.add(file2)

fileNum++

} else {

System.out.println("文件:" + file2.getAbsolutePath())

folderNum++

}

}

}

} else {

System.out.println("文件不存在!")

}

System.out.println("文件夹共有:" + folderNum + ",文件共有:" + fileNum)

}

在linux服务器上使用R语言及Rstudio server

cat /etc/redhat-release: 查看服务器系统版本

wget https://mirrors.tuna.tsinghua.edu.cn/CRAN/src/base/R-3/R-3.6.1.tar.gz

checking for rl_callback_read_char in -lreadline... no

configure: error: --with-readline=yes (default) and headers/libs are not available

configure: WARNING: you cannot build info or HTML versions of the R manuals

configure: WARNING: you cannot build PDF versions of the R manuals

configure: WARNING: you cannot build PDF versions of vignettes and help pages

6.安装

make

make install

安装成功!

R #在命令行直接输入“R”即可进入R 编辑。

q() ##退出R编辑

7.安装R-studio-server

wget https://download2.rstudio.org/server/centos6/x86_64/rstudio-server-rhel-1.2.1335-x86_64.rpm

yum install rstudio-server-rhel-1.2.1335-x86_64.rpm

8.R-studio-server的一些命令

rstudio-server start ##启动 rstudio

rstudio-server stop ## 关闭rstudio

rstudio-server status ## 查看rstudio 运行状态

运行rstudio-server status出现 “Active: active (running) ” 表示rstudio 已启动

rstudio-server verify-installation ## 查看rstudio 安装错误

rstudio-server restart ##重启

ifconfig ##查看服务器ip地址。

查看运行中R进程

rstudio-server active-sessions

指定PID,停止运行中的R进程

rstudio-server suspend-session <pid>

停止所有运行中的R进程

rstudio-server suspend-all

强制停止运行中的R进程,优先级最高,立刻执行

rstudio-server force-suspend-session <pid>

rstudio-server force-suspend-all

RStudio Server临时下线,不允许web访问,并给用户友好提示

rstudio-server offline

RStudio Server临时上线

rstudio-server online

8.rstudio-server系统设置

主要有两个配置文件,默认文件不存在(非必要,可不做修改)

/etc/rstudio/rserver.conf

/etc/rstudio/rsession.conf

vi /etc/rstudio/rserver.conf

www-port=8080#监听端口,默认是8787,可以不做修改

www-address=127.0.0.0#允许访问的IP地址,默认0.0.0.0

rstudio-server restart

vi /etc/rstudio/rsession.conf

session-timeout-minutes=30#会话超时时间

r-cran-repos= http://ftp.ctex.org/mirrors/CRAN #CRAN资源库

rsession-which-r=/usr/local/bin/R ## 如果非root安装,更改R所在目录。

9.通过浏览器连接Rstudio-server

直接打开浏览器,输入http://<服务器ip>:8787 ## 如果修改过rserver.conf文件,后面的8787端口改为相应的端口即可。

这里需要我们输入用户名和密码。关于用户名有2点注意事项:

(1).不允许使用system 用户登陆,即用户ids小于100的用户。只能用普通用户登录

(2).用户的认证可以使用RSA。

如果没有普通用户,可以添加:

useradd newname # 添加一个名为newname的用户

passwd newname###给新用户newname 设置密码,密码需是复杂密码,否则可能通不过。

usermod -G happy newname ####将新用户newname添加到happy 用户组中,

在用useradd添加用户之后,在默认的情况下,该账号是暂时被封锁的, 也就是说,该账号是无法登录,须要用passwd命令来给新创建的用户设置密码之后才可以使用。

10可能存在的问题

10.1如果你的rstudio-server没有启动 很大程度是安装有误,这里我将我遇到的错误分享出来

rstudio-server verify-installation

There is a libR.so in /usr/lib/R/lib, but (weirdly) ls -l reveals that

it dates from the my previous install of R-3.5.1 for which I did not

configure with --enable-R-shlib.

这里就提到无法找到libR.so文件,原因是配置R语言文件时,没有加参数--enable-R-shlib.

这就必须要重新安装R语言。使用make uninstall 删除之前的安装,最好也删除R-3.6.1所在的文件夹,用“rm -r -f R-3.6.1".

使用rm 命令 -r 参数表示全部删除, -f 参数表示强制删除,不会提醒。 同时使用这两个参数要小心。

10.2 普通用户无法启动rstudio-server

sudo rstudio-server start## 以管理员方式执行命令

这时会需要输入密码并提示

xxx is not in the sudoers file.This incident will be reported.

如果不想出现上面的提示,就是给该用户提高权限,添加用户使用sudo的权利。

su root ###切换到root用户,如果有root权限的话。

chmod u+w /etc/sudoers ###添加sudo文件的写权限

vi /etc/sudoers ###编辑sudoers文件,添加权限。

找到这行 root ALL=(ALL) ALL,在他下面添加xxx ALL=(ALL) ALL (这里的xxx是你的用户名)

youuserALL=(ALL)ALL

%youuser ALL=(ALL)ALL

youuserALL=(ALL)NOPASSWD: ALL

%youuser ALL=(ALL)NOPASSWD: ALL

chmod u-w /etc/sudoers ##撤销sudoers文件写权限