-
Notifications
You must be signed in to change notification settings - Fork 2
/
hw1-getting-started.Rmd
124 lines (92 loc) · 5.86 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
118
119
120
121
122
123
---
title: "Homework 1 - Getting Started"
output:
html_document:
number_sections: false
toc: no
---
> **Due**: 07 September by 11:00 pm
>
> **Weight**: This assignment is worth **4%** of your final grade.
>
> **Purpose**: The purposes of this assignment are:
>
> - To make sure you understand what you need to do to succeed in this class
> - To make sure you have properly set up the software and tools we will use this semester
> - To get started practicing basic concepts with R.
>
> **Skills & Knowledge**: After completing these exercises, you should be able to:
>
> - 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).
>
> **Assessment**: Each question indicates the % of the assignment grade, summing to 100%. The credit for each question will be assigned as follows:
>
> - 0% for not attempting a response.
> - 50% for attempting the question but with _major_ errors.
> - 75% for attempting the question but with _minor_ errors.
> - 100% for correctly answering the question.
>
> **Rules**:
>
> - Problems marked **SOLO** may not be worked on with other classmates, though you may consult instructors for help.
> - For problems marked **COLLABORATIVE**, you may work in groups of up to 3 students who are in this course this semester. You may not split up the work -- everyone must work on every problem. And you may not simply copy any code but rather truly work together.
> - Even though you work collaboratively, you still must submit your own solutions.
# Tasks
### 1) Class setup [SOLO, 10%]
For this class, you'll need to install some software and register for some tools. Go to the [course prep](L0-course-prep.html) page to get setup. Once you have joined the [class Slack](https://emse-p4a-f20.slack.com/), 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://twitter.com/ryancbriggs/status/1293543531496308736?s=20) and read the entire [Course Syllabus](syllabus.html) (actually read the whole thing). Then review the lessons from this week (see the readings for week 1 on the [schedule](schedule.html)).
### 3) Staying organized [SOLO, 10%]
Open RStudio and create a new R project called "hw1" (see the [lesson page](L1.2-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.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, GW Net ID, and the names of anyone you worked with on this assignment (your GW Net ID is the part of your email address before `"@gwu.edu"`):
```{r eval=FALSE}
# Name: Last, First
# GW Net ID: Insert your GWNetID 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 hw1.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](L1.2-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) Submit your files [SOLO, 10%]
Create a zip file of all the files in your R project folder for this assignment and submit the zip file on Blackboard (note: to receive full credit, your submission must follow the above format of using a correctly-named R Project and `.R` script).