RStudio read.xl working directory error

[亡魂溺海] 提交于 2021-01-28 03:23:35

问题


Hi guys I'm having difficulty loading .xlsx into RStudio - I'm not sure why RStudio can't see the file. Am I specifying the path for read_excel() wrong? Any ideas? Pretty new at R.

Thanks!

Windows 10 (64-bit) Version 0.99.491 & Version 0.99.840 read.xl 0.1.0

getwd() [1] "C:/Users/user/Documents/Work" read_excel(system.file("C:/Users/user/Documents/Work/Data.xlsx")) Error: '' does not exist in current working directory ('C:/Users/user/Documents/Work')


回答1:


The results of the system.file command are probably returning a blank character "":

system.file("C:/Users/user/Documents/Work/Data.xlsx")  
[1] ""

I'm not sure why this is the case. Instead, just try specifying the full path within the excel_sheets function, i.e.,

read_excel("C:/Users/user/Documents/Work/Data.xlsx")



回答2:


How did you save the file? Is the file saved as Data.xlsx? If so, please remove the extension .xlsx and then try to import with read_excel("Data.xlsx"). I faced the similar error and after removing the extension, it worked fine.



来源:https://stackoverflow.com/questions/34557318/rstudio-read-xl-working-directory-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!