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.
For this class, you’ll need to install some software and register for some tools. Go to the course prep 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 lessons from this week (see the readings for week 1 on the schedule).
Open RStudio and create a new R project called “hw1” (see the lesson page 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"
):
# 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.
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
.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).