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.

getwd()

Output:


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

R setwd() Function:

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

setwd("e:/MakeMeAnalyst/R/")

R dir() Function:

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

dir()

R ls() Function:

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

ls()

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