一 :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包



