R setwd()

KyraThompson's avatar
Published Oct 7, 2022
Contribute to Docs

The setwd() sets the current working directory to the file path specified.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn how to code and clean and manipulate data for analysis and visualization with the R programming language.
    • Beginner Friendly.
      14 hours

Syntax

setwd(directory)

The setwd() function returns the current directory before it is changed to the file path of the directory parameter string.

Example

The following example sets the working directory to the file path “/Users/kyra/Documents/students”:

setwd("/Users/kyra/Documents/students")

All contributors

Contribute to Docs

Learn R on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn how to code and clean and manipulate data for analysis and visualization with the R programming language.
    • Beginner Friendly.
      14 hours