[問題] 載入資料(已解決)

看板R_Language作者 (啊猛)時間7年前 (2018/07/11 12:26), 編輯推噓1(1011)
留言12則, 4人參與, 7年前最新討論串1/1
[問題類型]: 經驗諮詢(載入csv檔卻出現錯誤) [軟體熟悉度]: 新手(沒寫過程式,R 是我的第一次) [問題敘述]: 目前在上Udemy郭老師的R語言,在第43講的地方卡住,練習是 希望我們讀取老師提供的檔案boston-celtics-2007-08.csv 我是先將路徑指定到我的下載資料夾,並將老師提供的檔案也放置於此 downloads_windows <- "C/Users/Dell/Downloads/" 接著執行以下兩行(這兩行其實我看不太懂它的意思) csv_file <- "C/Users/Dell/Downloads/boston-celtics-2007-08.csv" csv_df <- read.csv(csv_file) 但在console出現以下錯誤訊息 Error in file(file, "rt") : cannot open the connection In addition: Warning message: In file(file, "rt") : cannot open file 'C/Users/Dell/Downloads/boston-celtics-2007-08.csv': No such file or directory 想請問各位專家哪裡出錯了,謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.112.25.99 ※ 文章網址: https://www.ptt.cc/bbs/R_Language/M.1531311993.A.385.html

07/11 20:35, 7年前 , 1F
you should put a : after your disk, like C:/datapath
07/11 20:35, 1F

07/11 20:36, 7年前 , 2F
The error message tell you that the file path is
07/11 20:36, 2F

07/11 20:36, 7年前 , 3F
incorrect
07/11 20:36, 3F

07/11 22:04, 7年前 , 4F
I should have checked it twice! many thanks
07/11 22:04, 4F

07/11 22:49, 7年前 , 5F
file.exists(csv_file)是TRUE還是FALSE?
07/11 22:49, 5F

07/11 22:49, 7年前 , 6F
如果是TRUE,問題就可能是權限了
07/11 22:49, 6F

07/11 22:49, 7年前 , 7F
如果是FALSE,就真的是你檔案放錯地方
07/11 22:49, 7F

07/11 22:49, 7年前 , 8F
或是打錯名字
07/11 22:49, 8F

07/11 22:50, 7年前 , 9F
可以試試看用list.files(dirname(csv_file))確定一
07/11 22:50, 9F

07/11 22:50, 7年前 , 10F
07/11 22:50, 10F

07/12 08:30, 7年前 , 11F
應該是檔名對了,但絕對路徑不完整...
07/12 08:30, 11F

07/15 13:29, 7年前 , 12F
謝謝以上版友
07/15 13:29, 12F
文章代碼(AID): #1RHVTvE5 (R_Language)
文章代碼(AID): #1RHVTvE5 (R_Language)