R Work Directory

Working directory is where R looking for your files. To find out what is your working directory run getwd() commands. Sometimes you want to work on other directory. What you need to do is to change working directory you desire by run command setwd(“path_to_work_directory”).

Get Working Directory
> getwd()

List Files
> list.files()

Create A Directory
> dir.create("newdir")

Create A File
> file.create("myfirstfile.R")

File Exist
> file.exists(("myfirstfile.R")

Copy File
> file.copy("myfirstfile.R", "mycopyfile.R")

Rename File
> file.rename("myfirstfile.R", "mysecondfile.R")

File Information
> file.info(("myfirstfile.R")

Change Working Directory
 setwd("F:/temp")  // Set working directory to F:\temp

List files
 dir()

Videos