Setting Your Working Directory (Windows)

R getwd() Function:

Working directory is the directory where R finds all R file for reading and writing. getwd() function returns an absolute filepath representing the current working directory of the R process.



[1] "C:/Users/Kalyan/Documents"

R setwd() Function:

setwd(dir) is used to set the working directory to dir.


R dir() Function:

dir() function lists all the files in a directory.


R ls() Function:

ls() is a function in R that lists all the object in the working environment.


It can be used in scenario where you want to clean the environment before running code. Below command will remove all the object from R environment.

rm(list = ls()) 

Download and Install RStudio on Windows

Getting Help with R