无法从RStudio中读取xlsx文件中的数据。

时间:2022-09-01 22:09:10

I have installed the required packages - gdata and ggplot2 and I have installed perl.

我已经安装了所需的包——gdata和ggplot2,我已经安装了perl。

library(gdata)
library(ggplot2)

# Read the data from the excel spreadsheet
df = data.frame(read.xls ("AssignmentData.xlsx", sheet = "Data", header = TRUE, perl = "C:\\Strawberry\\perl\\bin\\perl.exe"))

However when I run this I get the following error:

但是当我运行这个时,我得到了以下错误:

Error in xls2sep(xls, sheet, verbose = verbose, ..., method = method,  : 
  Intermediate file 'C:\Users\CLAIRE~1\AppData\Local\Temp\RtmpE3UYWA\file8983d8e1efc.csv' missing!
In addition: Warning message:
running command '"C:\STRAWB~1\perl\bin\perl.exe" "C:/Users/Claire1992/Documents/R/win-library/3.1/gdata/perl/xls2csv.pl"  "AssignmentData.xlsx" "C:\Users\CLAIRE~1\AppData\Local\Temp\RtmpE3UYWA\file8983d8e1efc.csv" "Data"' had status 2 
Error in file.exists(tfn) : invalid 'file' argument

1 个解决方案

#1


1  

Thanks to @Stibu I realised I had to set my work directory. This is the command you use to run in Rstudio; setwd("C/Documents..."). The file path is where the excel file is located.

感谢@Stibu,我意识到我必须设置我的工作目录。这是您在Rstudio中运行的命令;setwd(“C /文档…”)。文件路径是excel文件所在的位置。

#1


1  

Thanks to @Stibu I realised I had to set my work directory. This is the command you use to run in Rstudio; setwd("C/Documents..."). The file path is where the excel file is located.

感谢@Stibu,我意识到我必须设置我的工作目录。这是您在Rstudio中运行的命令;setwd(“C /文档…”)。文件路径是excel文件所在的位置。