Homework Two:

In this homework we are taking character and numeric values and converting them into dates. We are also taking dates and coverting them to other date formats.

Question 1

Write an R function that converts a date of the format “yyyymmdd” such as “20200325” to a date of the format “mm/dd/yyyy”. Your function should be able to handle a vector input. For example, if your input is c(20200312, 20201023, 20201225), the output should be a vector of with elements 3/12/2020 and 12/25/2020.

## [1] "2020-03-12" "2020-10-23" "2020-12-25"

Question 2

Write an R function that converts a date of the format “mm/dd/yyyy” such as “09/15/2020” or “9/15/2020” to a date of the format “month day yyyy” such as “Sep 15 2020”. It should be able to handle a vector input correctly.

## [1] "September 15 2020" "September 16 2020" "September 17 2020"
## [1] "Tuesday, September 15, 2020"   "Wednesday, September 16, 2020"
## [3] "Thursday, September 17, 2020" 
## [1] "259 - 2020" "260 - 2020" "261 - 2020"
## [1] "2 2020" "3 2020" "4 2020"