-
Notifications
You must be signed in to change notification settings - Fork 0
/
hw1-getting-started.Rmd
117 lines (84 loc) · 5.59 KB
/
hw1-getting-started.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
109
110
111
112
113
114
115
116
117
---
title: "Homework 1 - Getting Started"
output:
html_document:
toc: false
number_sections: false
params:
number: 1
submit: "https://u.pcloud.com/#page=puplink&code=7VYkZwH5KGzcgqRhFOMfHFFkIsjDuB8Iy"
purpose: |
The purposes of this assignment are to:
>
> - Make sure you understand what you need to do to succeed in this class
> - Make sure you have properly set up the software and tools we will use this semester
> - Get started practicing basic concepts with R.
>
> **Skills & Knowledge**: After completing these exercises, you should:
>
> - Be familiar with the main course tools: Slack, R, and RStudio.
> - Be familiar how to use R projects to stay organized.
> - Be able to use R to create and store values as objects with meaningful names.
> - Know how to compare values in R.
> - Know how to use arithmetic, relational, and logical operators in R.
> - Know the distinctions between how R handles different types of data types (numbers, strings, & logicals).
---
```{r child = file.path("child", "setup.Rmd")}
```
```{r child = file.path("child", "hw.Rmd")}
```
### 1) Class setup [SOLO, 10%]
For this class, you'll need to install some software and register for some tools. You should have already done this, but in case you haven't,go to the [course software](ref-course-software.html) page to get setup.
Once you have joined the [class slack](`r settings$slack`), make a post to the `#welcome` channel introducing yourself - provide your name, year / program, and something interesting about yourself.
### 2) Getting familiar with the course [SOLO, 10%]
Follow [Snoop's advice](https://www.youtube.com/watch?v=Tnlaokj1opA) and read the entire [Course Syllabus](syllabus.html) (actually read the whole thing). Then review the [schedule](schedule.html) and make sure to note important upcoming deadlines.
### 3) Staying organized [SOLO, 10%]
Open RStudio and create a new R project called "hw1" (see the [reading](r1.1-getting-started.html#RStudio_projects) for details on how to do this). Within your project, create a new R _script_ (a ".R" file) and save it as "hw1-netID.R", replacing "netID" with your netID (e.g., "hw1-jph.R"). When you save it, it should show up in the R project folder you just created. Finally, copy the following code to the top of this script and fill out your name, netID, and the names of anyone you worked with on this assignment (your netID is the part of your email address before `"@gwu.edu"`):
```{r eval=FALSE}
# Name: Last, First
# netID: Insert your netID here
# I worked with the following classmates on this assignment:
# 1) Name: Last, First
# 2) Name: Last, First
```
Write your responses to all other questions in this assignment in your R file.
### 4) Objects & Operators: Converting Time [COLLABORATIVE, 20%]
Create objects to store each of the following two values - be sure to use [meaningful variable names](r1.1-getting-started.html#Use_meaningful_variable_names) when creating your objects:
- The number of seconds in a minute
- The number of minutes in an hour
- The number of hours in a day
- The number of days in a typical year (not a leap year)
Now, say you have another object called `time_in_seconds` that contains an integer number of seconds (for example, `time_in_seconds <- 8675309`). Write code to convert the value stored in `time_in_seconds` into the units described below. Your solution may only use arithmetic operators and the objects you created (i.e. you may **not** use any numbers). You may also use the new objects you create in sequential order. For example, you may use the object created in part a) to create the object in part b), and so on.
a) The value of `time_in_seconds` in minutes
b) The value of `time_in_seconds` in hours
c) The value of `time_in_seconds` in days
d) The value of `time_in_seconds` in years
### 5) Logical and relational operators [SOLO, 20%]
Consider the following objects:
```{r}
w <- FALSE
x <- TRUE
y <- FALSE
z <- TRUE
```
Write code to answer the following questions:
a) Write a statement with _logical_ operators that compares the objects `x`, `y`, and `z` and returns `TRUE`
b) Write a statement with _logical_ operators that compares the objects `x`, `y`, and `z` and returns `FALSE`
c) Fill in _relational_ operators to make the following statement return `TRUE`:
`! (x __ y) & ! (z __ y)`
d) Fill in _relational_ operators to make this statement return `FALSE`:
`! (w __ y) | (z __ y)`
### 6) Data types [COLLABORATIVE, 20%]
Consider the following objects:
```{r}
number <- typeof('3')
character <- typeof(7)
false <- typeof("FALSE")
true <- typeof(TRUE)
```
Write code to answer the following questions:
a) Write a statement with both _relational_ & _logical_ operators that compares the four objects `number`, `character`, `false`, and `true` and returns `TRUE`.
b) Write a statement with both _relational_ & _logical_ operators that compares the four objects `number`, `character`, `false`, and `true` and returns `FALSE`.
### 7) Read and reflect [SOLO, 10%]
Read and reflect on next week's readings on [functions & packages](r2-functions-packages.html). Afterwards, in a comment (`#`) in your R file, write a short reflection on what you've learned and any questions or points of confusion you have about what we've covered thus far. This can just few a few sentences related to this assignment, next week's readings, things going on in the world that remind you something from class, etc. If there's anything that jumped out at you, write it down.
> In case you missed them, instructions for how to submit your assignment are at the [top of this page](hw1-getting-started.html).