Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update 00-before-we-start.Rmd #880

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions episodes/00-before-we-start.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,25 @@ developing in R, RStudio will make typing easier and less error-prone.

## Getting set up

It is good practice to keep a set of related data, analyses, and text
self-contained in a single folder, called the **working directory**. All of the
### The working directory

The working directory is an important concept. It is the location
where R will look for and save files while you are working on a project.

RStudio assists you in this regard and sets the working directory automatically
to the directory where you have placed your project. If you need to check your
current working directory, you can use `getwd()`. If for some reason your current
working directory is not what it should be, you can change it in the
RStudio interface by navigating in the file browser where your working directory
should be, and clicking on the blue gear icon "More", and select "Set As Working
Directory". Alternatively you can use `setwd("/path/to/working/directory")` to
change your working directory. However, your scripts should not include this line
because it will fail on someone else's computer.

### Setting up

It is good practice when working on a project to keep all related data, analyses, and text
self-contained in a single folder, referred to as the **working directory**. All of the
scripts within this folder can then use *relative paths* to files that indicate
where inside the project a file is located (as opposed to absolute paths, which
point to where a file is on a specific computer). Working this way allows you to
Expand Down Expand Up @@ -240,23 +257,6 @@ Your working directory should now look like this:
knitr::include_graphics("fig/r-starting-how-it-should-look-like.png")
```

### The working directory

The working directory is an important concept to understand. It is the place
from where R will be looking for and saving the files. When you write code for
your project, it should refer to files in relation to the root of your working
directory and only need files within this structure.

RStudio assists you in this regard and sets the working directory automatically
to the directory where you have placed your project in.
If you need to check it, you can use `getwd()`. If for some
reason your working directory is not what it should be, you can change it in the
RStudio interface by navigating in the file browser where your working directory
should be, and clicking on the blue gear icon "More", and select "Set As Working
Directory". Alternatively you can use `setwd("/path/to/working/directory")` to
reset your working directory. However, your scripts should not include this line
because it will fail on someone else's computer.

## Interacting with R

The basis of programming is that we write down instructions for the computer to
Expand Down