一、加载包:
install.packages("xlsx")
Installing package into ‘/home/jiandong/R/i686-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘xlsxjars’
试开URL’https://cloud.r-project.org/src/contrib/xlsxjars_0.6.1.tar.gz'
Content type 'application/x-gzip' length 9477071 bytes (9.0 MB)
==================================================
downloaded 9.0 MB
试开URL’https://cloud.r-project.org/src/contrib/xlsx_0.5.7.tar.gz'
Content type 'application/x-gzip' length 312839 bytes (305 KB)
==================================================
downloaded 305 KB
* installing *source* package ‘xlsxjars’ ...
** 成功将‘xlsxjars’程序包解包并MD5和检查
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded
* DONE (xlsxjars)
* installing *source* package ‘xlsx’ ...
** 成功将‘xlsx’程序包解包并MD5和检查
** R
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded
* DONE (xlsx)
The downloaded source packages are in
‘/tmp/RtmpjYbp3s/downloaded_packages’
到这里显示安装读取excel的包成功。
如果失败,可能是缺少Rjava和xlsxjars,看下面的帖子自己解决:
Rjava安装问题
看一下原始数据:
library("xlsx", lib.loc="~/R/i686-pc-linux-gnu-library/3.4")
载入需要的程辑包:rJava
载入需要的程辑包:xlsxjars
> read.xlsx('/home/jiandong/桌面/data.xlsx')
Error in read.xlsx("/home/jiandong/桌面/data.xlsx") :
Please provide a sheet name OR a sheet index.
报错:提示需要指定读入那个sheet的数据,那就修改代码如下:
> read.xlsx('/home/jiandong/桌面/data.xlsx','Sheet1')
X1 X2 X3 X4
1 2 3 4 5
2 3 4 5 6
3 4 5 6 7
4 5 6 7 8
5 6 7 8 9
6 7 8 9 10
7 8 9 10 11
8 9 10 11 12
9 10 11 12 13
10 11 12 13 14
11 12 13 14 15
读取成功。



雷达卡






京公网安备 11010802022788号







