Setting the Working Directory

You do not have to type the drive name and folder name every time you want to read or write a file, so if you use the same path frequently it is sensible to set the working directory using the setwd function:

setwd("c:\\temp")

...

...
read.table("daphnia.txt",header=T)

If you want to find out the name of the current working directory, use getwd():

getwd()

[1]  "c:/temp"

Get The R Book now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.