Create a R Project using R Studio
Create sub-folders inside your R project directory (either using R Studio or in Finder/Computer)
Move your data file to the corresponding sub-folder outside of R studio
Go back to R Studio (double click the R project). Create a new R
markdown file and save it inside the corresponding sub-folder
Example of a R project structure:
load the libraries for importing data
library(rio)
library(here)
## here() starts at /Users/BerniceCheung/Dropbox (University of Oregon)/Teaching/psy611
here
function to specify the location of the
data file inside the import
function. The here
function always starts with the folder where your R project locates.
Enter the name of the sub-folder (can be multiple lyers of sub-folders)
to specify the location, then enter the file name.df <- import(here('data', 'wave1', 'data.csv'))
Check more information about R project here
Couldn't find the file
:
check if your R project is open in R Studio (Always open your r script by double clicking the R project)
check if the file is inside the sub-folder you specify in
here
.
check the file name and the file extension name.