Files Handeling
For reading and writing data we recoomend use the library under tidyverse
Documents folder.setwd(PATH/TO/NEW/WORKING/DIRECTORY) to change the working directory.getwd() to see your current working directory.Consider the following file structure
Using read_csv() to read the data
read_csv() need to specify WHERE do you put the file by Absolute path or Relative path.rmd) to run the above code then you need to put in the same directoryThere are two ways of specifying a path:
Absolute Path
An absolute path starts from the root directory (/) and specifies the full path to a file or directory.
THIS_RMD.rmd: /home/user/documents/course/THIS_RMD.rmdIMAGE.png: /home/user/downloads/IMAGE.pngReminder for Windows system
\ instead of / in your file explorer. In R, you need to transform these \s to / if you directly copy and paste the file path.C:\Users\Ray\Blah\BlahRelative Path
A relative path is defined relative to the current working directory.
getwd() to get current working directory
setwd('A PATH') to set new working directory
./ refers to the current directory,
../ means “go up one directory level”.
Assume that we are working on THIS_RMD.rmd, so the current directory is /home/user/documents/course.
myData.csv : ./myData.csv or myData.csvIMAGE.png: ../../downloads/IMAGE.png