Due: January 19 by 11:59pm
Submit: To submit this assignment, create a zip file of all the files in your R project folder for this assignment. Name the zip file
hw1-netID.zip
, replacingnetID
with your netID (e.g.,hw1-jph.zip
). Use this link to submit your file.Weight: This assignment is worth 5% 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
- 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).
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.
The reflection portion is always worth 10% and graded for completion.
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 and submit your own solutions.
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 page to get setup.
Once you have joined the class slack, make a post to
the #welcome
channel introducing yourself - provide your
name, year / program, and something interesting about yourself.
Follow Snoop’s advice and read the entire Course Syllabus (actually read the whole thing). Then review the schedule and make sure to note important upcoming deadlines.
Open RStudio and create a new R project called “hw1” (see the reading 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"
):
# 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.
Create objects to store each of the following two values - be sure to use meaningful variable names when creating your objects:
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.
time_in_seconds
in minutestime_in_seconds
in hourstime_in_seconds
in daystime_in_seconds
in yearsConsider the following objects:
w <- FALSE
x <- TRUE
y <- FALSE
z <- TRUE
Write code to answer the following questions:
x
, y
, and z
and returns
TRUE
x
, y
, and z
and returns
FALSE
TRUE
:! (x __ y) & ! (z __ y)
FALSE
:! (w __ y) | (z __ y)
Consider the following objects:
number <- typeof('3')
character <- typeof(7)
false <- typeof("FALSE")
true <- typeof(TRUE)
Write code to answer the following questions:
number
, character
, false
, and
true
and returns TRUE
.number
, character
, false
, and
true
and returns FALSE
.Read and reflect on next week’s readings on functions & packages.
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.