R语言read.xlsx()解读

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Ssxysxy123/article/details/51436213

read.xlsx(file, sheetIndex, sheetName=NULL, rowIndex=NULL,startRow=NULL, endRow=NULL, colIndex=NULL,as.data.frame=TRUE, header=TRUE, colClasses=NA,keepFormulas=FALSE, encoding="unknown", ...)

file文件读取的路径

sheetIndex 在工作簿中表示的表索引的数字

sheetName 工作簿中表示的表索引的名称

rowIndex/colIndex 为空则提取所有行/列数据,数字向量指定想要提取的行/列

as.data.frame a logical value indicating if the result should be coerced into a data.frame. If FALSE, the result is a list with one element for each column.

header T or F,指定读取表格的第一行是否包含变量名称

colClassesFor read.xlsx a character vector that represent the class of each column. Recycled as necessary, or if the character vector is named, unspecified values are taken to be NA. For read.xlsx2 see readColumns.

keepFormulas a logical value indicating if Excel formulas should be shown as text in R and not evaluated before bringing them in.

encoding设定字符串编码格式

startRow/endRow指定要开始/结束读取数据的行数 

       

read.xls()需要加载xls包,要求读入文件为Excel2007及以上版本;但是网上说数据量大时用xlsx包有时会出错,而且速度极慢

网上搜到另外一种读取execl表中部分数据的方法,觉得R这种读法简直是酷毙了

在execl表格中圈住想要读取的数据部分,选择“复制”,在R中执行命令read.table("clipboard")可以直接读出选中的数据

更为习惯的读取execl的方法是保存为csv格式即逗号分隔文件,用read.csv()读取。


猜你喜欢

转载自blog.csdn.net/Ssxysxy123/article/details/51436213