-
Notifications
You must be signed in to change notification settings - Fork 92
/
Copy path01_install.Rmd
67 lines (40 loc) · 3.63 KB
/
01_install.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# (PART) Get your R act together {-}
# Install R and RStudio {#install}
```{r include = FALSE}
source("common.R")
```
<!--Original content: https://stat545.com/block000_r-rstudio-install.html-->
## R and RStudio
* Install [R, a free software environment for statistical computing and graphics][r-proj] from [CRAN][cran], the Comprehensive R Archive Network. I __highly recommend__ you install a precompiled binary distribution for your operating system -- use the links up at the top of the CRAN page linked above!
* Install RStudio's IDE (stands for _integrated development environment_), a powerful user interface for R. Get the Open Source Edition of RStudio Desktop.
- I __highly recommend__ you run the [Preview version][rstudio-preview]. I find these quite stable and you'll get the cool new features! Update to new Preview versions often.
- Of course, there are also official releases available [here][rstudio-official].
- RStudio comes with a __text editor__, so there is no immediate need to install a separate stand-alone editor.
- RStudio can __interface with Git(Hub)__. However, you must do all the Git(Hub) set up [described elsewhere][happy-git] before you can take advantage of this.
If you have a pre-existing installation of R and/or RStudio, we __highly recommend__ that you reinstall both and get as current as possible. It can be considerably harder to run old software than new.
* If you upgrade R, you will need to update any packages you have installed. The command below should get you started, though you may need to specify more arguments if, e.g., you have been using a non-default library for your packages.
``` r
update.packages(ask = FALSE, checkBuilt = TRUE)
```
__Note:__ this will only look for updates on CRAN. So if you use a package that lives *only* on GitHub or if you want a development version from GitHub, you will need to update manually, e.g. via `devtools::install_github()`.
## Testing testing
* Do whatever is appropriate for your OS to launch RStudio. You should get a window similar to the screenshot you see [here][rstudio-workbench], but yours will be more boring because you haven't written any code or made any figures yet!
* Put your cursor in the pane labelled Console, which is where you interact with the live R process. Create a simple object with code like `x <- 2 * 4` (followed by enter or return). Then inspect the `x` object by typing `x` followed by enter or return. You should see the value 8 print to screen. If yes, you've succeeded in installing R and RStudio.
## Add-on packages
R is an extensible system and many people share useful code they have developed as a _package_ via CRAN and GitHub. To install a package from CRAN, for example the [dplyr][dplyr-cran] package for data manipulation, here is one way to do it in the R console (there are others).
```r
install.packages("dplyr", dependencies = TRUE)
```
By including `dependencies = TRUE`, we are being explicit and extra-careful to install any additional packages the target package, dplyr in the example above, needs to have around.
You could use the above method to install the following packages, all of which we will use:
* tidyr, [package webpage][tidyr-web]
* ggplot2, [package webpage][ggplot2-web]
## Further resources
The above will get your basic setup ready but here are some links if you are interested in reading a bit further.
* [How to Use RStudio][rstudio-support]
* [RStudio's leads for learning R][rstudio-R-help]
* [R FAQ][cran-faq]
* [R Installation and Administration][cran-R-admin]
* [More about add-on packages in the R Installation and Administration Manual][cran-add-ons]
```{r links, child="links.md"}
```