-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathr.rmd
108 lines (78 loc) · 2.84 KB
/
r.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
layout: page
title: Introduction to R page
---
Installing
----------
You should gain access to a laptop and bring it to your tutorial. If
this will be a problem for you, please communicate with Dushoff.
Install and run the program R from
<http://cran.r-project.org/bin/windows/base/>
(windows) or
<http://cran.r-project.org/bin/macosx/>
(mac).
*You should try this step before your tutorial*.
In each case you want to download and then run the first file on the page.
You should also install RStudio (http://www.rstudio.com/ide/). It's
possible to do everything in plain R, but RStudio will enhance your
experience, and it will be the way the TAs teach things.
Command line {#command_line}
------------
R gives you a command line where you can type commands. For example,
type
`2+2`
followed by <enter>
to see what R thinks the sum is.
Type `q()` to quit. The parentheses are weird, they let R know that q is
a *function* it is supposed to try to execute, in this case by quitting.
After you type `q()` R will ask you some sort of confusing question:
answer either yes or no, it probably shouldn't matter.
If R ever gets confused, you should be able to get it to give you an
error and go back to normal by typing `;` and then <enter>
. If that
doesn't work, try `";` (it's hard to make a single quote in Rstudio,
though). If that doesn't work, kill the window by force and start over.
Library
-------
The time plots in bd use something called deSolve, which may not be
installed with your version of R. You can install it by typing:
```
install.packages("deSolve")
```
or by clicking on "packages" at the menu on top of the **lower right**
Rstudio window.
**You only have to do this once per installation of R.**
The function {#the_function}
------------
To load `bd`, type:
```{r}
source("https://raw.githubusercontent.com/Bio3SS/Exponential_figures/master/bd.R")
```
This should work if you are connected to the internet. `source` is a
function; it tells R to load some information. The thing inside the
parentheses is an argument; it tells R what information to load.
You can also open [the file](https://raw.githubusercontent.com/Bio3SS/Birth_death_models/master/bd.R) directly, or right-click to save it to your computer.
Running
-------
Now you have loaded a function. Let's try running it.
Type:
```{r}
bd()
```
That's basically what you need from the introduction.
Exploring further
-----------------
We can learn more about `bd` by using the function `args`; this tells
you what arguments the function takes:
```{r}
args(bd)
```
Everything in the parentheses is an argument that tells the function
what to do. You should be able to change it to make the function do
something else. For example, try typing:
```{r}
bd(bDD=40)
```
- For more information on `bd`, see
[The BirthDeath page](bd.export.html)
- Trouble? See [R troubleshooting](/trouble.html)