Get Path of Currently Executing Script in R (Example Code)
This tutorial illustrates how to find the file location of the currently executing R script in R programming.
Example: Returning Location of Currently Used R File
install.packages("rstudioapi") # Install rstudioapi package library("rstudioapi") # Load rstudioapi package |
install.packages("rstudioapi") # Install rstudioapi package library("rstudioapi") # Load rstudioapi package
getSourceEditorContext()$path # Using getSourceEditorContext function # "C:/Users/Data Hacks/Desktop/My_R_File.R |
getSourceEditorContext()$path # Using getSourceEditorContext function # "C:/Users/Data Hacks/Desktop/My_R_File.R