-
Notifications
You must be signed in to change notification settings - Fork 1
/
exercise1.Rmd
91 lines (64 loc) · 1.44 KB
/
exercise1.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
## Exercice 1. Getting started ~ 10 minutes
Create the script "exercise1.R" (in R Studio: File -> New File) and save it to the "Rcourse/Module1" directory: you will save all the commands of exercise 1 in that script.
<br>Remember you can comment the code using #.
**1- From the console, go to Rcourse/Module1.
First check where you currently are with getwd();
then go to Rcourse/Module1 with setwd()**.
Remember that **~** is a shortcut to your home directory.
<details>
<summary>
*Answer*
</summary>
```{r, eval=FALSE}
getwd()
setwd("Rcourse/Module1")
setwd("~/Rcourse/Module1")
```
</details>
**2- Using R as a calculator, calculate the square root of 654 (don't know the function? Search the internet!).**
<details>
<summary>
*Answer*
</summary>
```{r}
sqrt(654)
```
</details>
**3- Create a new object "myobject" that contains value 60.
Show "myobject" in the console.**
<details>
<summary>
*Answer*
</summary>
```{r}
myobject <- 60
myobject
```
</details>
**4- Subtract 1 from myobject. Reassign.**
<details>
<summary>
*Answer*
</summary>
```{r}
myobject <- myobject - 1
```
</details>
**5- Create a new object "mysqrt" that will store the square root of "myobject".**
<details>
<summary>
*Answer*
</summary>
```{r}
mysqrt <- sqrt(myobject)
```
</details>
**6- Create a new object "mydiv" that will store the result of "myobject" divided by "mysqrt".**
<details>
<summary>
*Answer*
</summary>
```{r}
mydiv <- myobject / mysqrt
```
</details>