- This topic has 1 reply, 2 voices, and was last updated 2 years, 4 months ago by .
Viewing 1 reply thread
Viewing 1 reply thread
You must be logged in to reply to this topic. Login here
Tagged: Rstudio
คำสั้ง read data ตัว file data จะต้องอยู่ใน directory/subdirectory ไหนคะ ลองสร้าง data บน excel แล้ว save as CSV เก็บไว้ใน c:folder/data.csv แต่ run ตำสั่ง read มันขึ้น
read.csv(“data.csv”)
Error in file(file, “rt”) : cannot open the connection
In addition: Warning message:
In file(file, “rt”) :
cannot open file ‘data.csv’: No such file or directory
ถ้าเราไม่set working directory ก่อนเราต้องบอก path ให้ครบค่ะ ต้องใส่ read.csv(“C:/folder/data.csv”) หรืถ้าset working directory ตามVDO ที่ชี้แจงไว้จะสามารถเรียก command ที่ว่าได้และไม่มี error ค่ะ
setwd(“C:/folder/”)
read.csv(“data.csv”)
อย่าลืมว่าถ้าจะใช้ data ในการคำนวณต่อต้อง assign name ให้ data ด้วยนะคะ เช่น
new.dt <- read.csv("C:/folder/data.csv")
หรือ
setwd("C:/folder/")
new.dt <- read.csv("data.csv")
You must be logged in to reply to this topic. Login here