Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

If you ever forget the path to your working directory, type

> getwd()
in the Console pane, and R returns the path onscreen.
In the Console pane, you don’t type the right-pointing arrowhead at the begin-
ning of the line. That’s a prompt.
My working directory looks like this:
> getwd()
[1] “C:/Users/Joseph Schmuller/Documents
Note which way the slashes are slanted. They’re opposite to what you typically see
in Windows file paths. This is because R uses \ as an escape character, meaning
that
whatever follows the \ means something different from what it usually means.
For example, \t in R means Tab key.
You can also write a Windows file path in R as
C:\\Users\\<User Name>\\Documents
If you like, you can change the working directory:
> setwd(<file path>)
Another way to change the working directory is to select
Session ➪ Set Working Directory ➪ Choose Directory
So let’s get started, already
And now for some R! In the Script window, type
x <- c(3,4,5)
and then Ctrl+R.
That puts the following line into the Console pane:
> x <- c(3,4,5)

You might also like