What is the getwd() function in R?

Overview

The getwd() function is used to return the current working directory in an R process.

Syntax

getwd()

Parameter value

The getwd() function takes no parameter values.

Return value

The getwd() function returns the current working directory.

Note: If the working directory is not available, it returns a character string NULL.

Example

# invoking the getwd() function
getwd()

Explanation

In the code above, we use the getwd() function to return the working directory of the R program.

Note: The code file shown above is placed in a folder named usercode, which is at the root of the path. This is why the output is /usercode.

New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources