How to get the path of current script in R ? Last Updated : 30 May, 2021 Summarize Comments Improve Suggest changes Share Like Article Like Report In this article, we will see how to determine the path of the current script in R Programming Language. Method 1: Traditional method If we want to check the current directory of the R script, we can use getwd( ) function. For getwd( ), no need to pass any parameters. If we run this function we will get the current working directory or current path of the R script. To change the current working directory we need to use a function called setwd( ). We need to pass the path as a parameter. syntax : getwd( ) Example : R getwd() Output : Method 2: Using rstudioapi package To use the functions of rstudioapi we need to install this package first. To install this package type the below command in the terminal. install.packages(rstudioapi) From rstudioapi package we need to use getSourceEditorConext(). It's like a list. We need to retrieve the path from it. So we need to use $ operator along with getSourceEditorConext(). Before executing this we need to save the R script with some name and with .R extension. Then run the below code for getting the current path of R script. Example : R # importing rstudioapi package library("rstudioapi") # retrieving path from getSourceEditorContext() # using $ operator getSourceEditorContext()$path Output : Method 3: Using here Library In the here library we are going to use here( ) function. This function determines the path of the current R script. No need to pass any parameters. Just import the library using the library( ) function. If the package is not available, install using install.packages( ) function by passing package name as parameter within quotations. After installing package, call here( ) function. Syntax : here( ) Example : R library("here") here() Output : Comment More infoAdvertise with us Next Article How to get the current pathname in the app directory of Next.js? K krishnakarthikeyakhandrika Follow Improve Article Tags : R Language R directory-programs Similar Reads How to Get the Path of Current Script using Node.js ? In Node JS, getting the path of the current script is useful for file operations, logging, and configuration. It allows you to access related files or directories reliably, regardless of where your Node.js process was started.ApproachTo get the path of the present script in node.js we will be using 2 min read How to get the current pathname in the app directory of Next.js? NextJS is a React framework that is used to build full-stack web applications. It is used both for front-end as well as back-end. It comes with a powerful set of features to simplify the development of React applications. In this article, we will learn about How to get the current pathname in the ap 3 min read How to Get the Full Path of a File in Linux While dealing with files on Linux, especially shell scripts, one may require determining the full path of a file at times. Now, let's consider several methods of getting the full path of a file in Linux. In this article, we will be discussing several different solutions to a popular problem.Before w 3 min read How to print command line arguments passed to the script in Node.js ? Node.js is an open-source and cross-platform runtime environment built on Chrome's V8 engine that enables us to use JavaScript outside the browser. Node.js helps us to use build server-side applications using JavaScript. In Node.js if you want to print the command line arguments then we can access 2 min read How to Use the (?) Operator in R The ? operator in R is a simple yet powerful tool that provides quick access to documentation and help pages for functions, datasets, and other objects within the R environment. Understanding how to effectively use this operator can significantly enhance your productivity and help you learn R Progra 4 min read How to Access the Script/Source History in RStudio? RStudio provides several tools for managing and revisiting your code where one of the great featured tool is the Script/Source History feature. This feature allows you to view and access previous commands and scripts, which can be particularly useful for tracking changes, debugging, or revisiting ea 5 min read Like