setwd() Error in R – cannot change working directory (2 Examples)
In this article you’ll learn how to avoid the “Error in setwd() : cannot change working directory” in the R programming language.
Example 1: Replicating the Error – cannot change working directory
setwd("C:/Users/Data Hacks/Desktop/My Directory") # "My Directory" does not exist # Error in setwd("C:/Users/Data Hacks/Desktop/My Directory") : # cannot change working directory |
setwd("C:/Users/Data Hacks/Desktop/My Directory") # "My Directory" does not exist # Error in setwd("C:/Users/Data Hacks/Desktop/My Directory") : # cannot change working directory
Example 2: Solving the Error – cannot change working directory
setwd("C:/Users/Data Hacks/Desktop/") # Use existing working directory |
setwd("C:/Users/Data Hacks/Desktop/") # Use existing working directory