栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 云计算 > 云平台

R语言导入excel表格数据——Please provide a sheet name OR a sheet index.

云平台 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

R语言导入excel表格数据——Please provide a sheet name OR a sheet index.

一 :xlsx包 

> install.packages("xlsx")
WARNING: Rtools is required to build R packages but is not currently installed. Please download and install the appropriate version of Rtools before proceeding:

https://cran.rstudio.com/bin/windows/Rtools/
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/xlsx_0.6.5.zip'
Content type 'application/zip' length 375273 bytes (366 KB)
downloaded 366 KB

package ‘xlsx’ successfully unpacked and MD5 sums checked

The downloaded binary packages are in
	C:UsersLenovoAppDataLocalTempRtmpKSASFHdownloaded_packages
> library(xlsx)

> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx')
Error in read.xlsx("D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx") : 
  Please provide a sheet name OR a sheet index.

> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',rowNames=T)
Error in read.xlsx("D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx", rowNames = T) : 
  Please provide a sheet name OR a sheet index.

> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',1)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.util.SAXHelper (file:/D:/R/R-4.1.3/library/xlsxjars/java/poi-ooxml-3.10.1-20140818.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int)
WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.SAXHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',1,rowNames=T)

常报错:Please provide a sheet name OR a sheet index.

> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',rowNames=T)
Error in read.xlsx("D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx", rowNames = T) : 
  Please provide a sheet name OR a sheet index.
> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',rowNames=T)
Error in read.xlsx("D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx", rowNames = T) : 
  Please provide a sheet name OR a sheet index.

解决办法:

1、

#一般方法,在后面加一个1
> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',1)
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.util.SAXHelper (file:/D:/R/R-4.1.3/library/xlsxjars/java/poi-ooxml-3.10.1-20140818.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int)
WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.SAXHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

#更好一点的解决办法:
#因为文件的第一列是无关数据(eg:序号),设置rowNames=Ture,即让第一列不参与运算 
> seaside=read.xlsx('D:/大三下/多元统计分析R语言/实验报告/4-1.xlsx',1,rowNames=T)

2、换一个包:openxlsx包

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/896964.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号