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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources