-
Notifications
You must be signed in to change notification settings - Fork 3
/
hw_week_01.Rmd
79 lines (41 loc) · 2.03 KB
/
hw_week_01.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
---
title: "EEEB UN3005/GR5005 \nHomework - Week 01 - Due 04 Feb 2020"
author: "USE THE NUMERIC PORTION OF YOUR UNI HERE"
output: pdf_document
fontsize: 12pt
---
```{r setup, include = FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
**Homework Instructions:** Complete this assignment by writing code in the code chunks provided. If required, provide written explanations below the relevant code chunks. Replace "USE THE NUMERIC PORTION OF YOUR UNI HERE" in the document header with the numbers appearing in your UNI. When complete, knit this document within RStudio to generate a PDF file. Please review the resulting PDF to ensure that all content relevant for grading (i.e., code, code output, and written explanations) appears in the document. Rename your PDF document according to the following format: hw_week_01_UNInumbers.pdf. Upload this final homework document to CourseWorks by 5 pm on the due date.
## Problem 1 (3 points)
Perform the following calculations in R code:
a) 372 divided by 7.5
```{r}
```
b) 14 squared
```{r}
```
c) Assign an object called `x` the sum of 24.7, 8.1, and 40. Show the resulting value of `x`.
```{r}
```
## Problem 2 (3 points)
a) Assign an object called `my.nums` the values -6, 0, 6, and 12 using the `c()` function. Show the resulting values of `my.nums`.
```{r}
```
b) Assign an object called `my.nums2` the values -6, 0, 6, and 12 using the `seq()` function. Show the resulting values of `my.nums2`.
```{r}
```
## Problem 3 (4 points)
a) Assign an object called `my.favs` the names of five of your favorite organisms (the scientific names). Show the resulting values of `my.favs`.
```{r}
```
b) Use bracket indexing (the `[ ]` functionality) to display only the second element in your `my.favs` vector.
```{r}
```
c) Use a combination of bracket indexing and the `:` operator to display the third *through* fifth elements in your `my.favs` vector.
```{r}
```
d) Run the line of code `rep(my.favs, times = 3)`. Describe (in written text below the code chunk) what this function is doing.
```{r}
```