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
getSourceEditorContext()$path    # Using getSourceEditorContext function
# "C:/Users/Data Hacks/Desktop/My_R_File.R

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed