Due: 07 September by 11:00 pm

Weight: This assignment is worth 4% of your final grade.

Purpose: The purposes of this assignment are:

Skills & Knowledge: After completing these exercises, you should be able to:

Assessment: Each question indicates the % of the assignment grade, summing to 100%. The credit for each question will be assigned as follows:

Rules:

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 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.

2) Getting familiar with the course [SOLO, 10%]

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).

3) Staying organized [SOLO, 10%]

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.

4) Objects & Operators: Converting Time [COLLABORATIVE, 20%]

Create objects to store each of the following two values - be sure to 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.

  1. The value of time_in_seconds in minutes
  2. The value of time_in_seconds in hours
  3. The value of time_in_seconds in days
  4. The value of time_in_seconds in years

5) Logical and relational operators [SOLO, 20%]

Consider the following objects:

w <- FALSE
x <- TRUE
y <- FALSE
z <- TRUE

Write code to answer the following questions:

  1. Write a statement with logical operators that compares the objects x, y, and z and returns TRUE
  2. Write a statement with logical operators that compares the objects x, y, and z and returns FALSE
  3. Fill in relational operators to make the following statement return TRUE:

! (x __ y) & ! (z __ y)

  1. Fill in relational operators to make this statement return FALSE:

! (w __ y) | (z __ y)

6) Data types [COLLABORATIVE, 20%]

Consider the following objects:

number    <- typeof('3')
character <- typeof(7)
false     <- typeof("FALSE")
true      <- typeof(TRUE)

Write code to answer the following questions:

  1. Write a statement with both relational & logical operators that compares the four objects number, character, false, and true and returns TRUE.
  2. 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).


EMSE 4574: Programming for Analytics (Fall 2020) |
Tuesdays | 12:45 - 3:15 PM | Dr. John Paul Helveston | jph@gwu.edu
Content 2020 John Paul Helveston. See the licensing page for details.