Chapter 3. Navigating the Software
R is a big chunk of software, first and foremost. You will inevitably spend time doing what one does with any big piece of software: configuring it, customizing it, updating it, and fitting it into your computing environment. This chapter will help you perform those tasks. There is nothing here about numerics, statistics, or graphics. This is all about dealing with R as software.
3.1. Getting and Setting the Working Directory
You want to change your working directory. Or you just want to know what it is.
- Command line
getwdto report the working directory, and use
setwdto change it:
getwd() "/home/paul/research" >
From the main menu, select File → Change dir... .
- OS X
From the main menu, select Misc → Change Working Directory.
For both Windows and OS X, the menu selection opens the current working directory in a file browser. From there, you can navigate to a new working directory if desired.
Your working directory is important because it is the default location for all file input and output—including reading and writing data files, opening and saving script files, and saving your workspace image. When you open a file and do not specify an absolute path, R will assume that the file is in your working directory.
The initial working directory depends upon how you started R. See Recipe 1.2.
See Recipe 4.5 for dealing with filenames in Windows. ...