Skip to content

Instantly share code, notes, and snippets.

@davan690
Created September 8, 2020 23:29
Show Gist options
  • Save davan690/a30fb970b5dd866297e228e0926edcee to your computer and use it in GitHub Desktop.
Save davan690/a30fb970b5dd866297e228e0926edcee to your computer and use it in GitHub Desktop.
Understanding files paths in Rstudio and R 4.0.1
# Make sure you have the project running through RStudio with a "project" file within the root directory.
#libraries
library(here)
library(tidyverse)
# 1. Place R scripts in folder within the root directory (project file location)
# 2. Source file from this location in RMD file
source("./R/Rscriptv1.R")
# Note that this wil not work if the location of "./R/Rscriptv1.R" has been changed since first importing data etc
# TO fix this with the same core R directory use the here function like so:
source(here::here("./R/Rscriptv1.R"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment