Introduction to Business Analytics with R

```{r}

```

Creatibg a datetime object d from the character string “05/08/2020”

d <- as.date(date_string, format = “%m/%d/%Y”) # Checking the data type of the d object by printing it print(d)

#Loading the lubricate package library(lubridate)

Extracting year,month, week number, and weekday number

d_year <- year(d) d_month <- month(d) d_week <- week(d) d_day <- wday(d)

Displaying the extracted values

print(d_year) print(d_month) print(d_week) print(d_day)

Creating a datetime object d_25 which is 25 days from the date in d

d_25 <- d+25 # Displaying the d_25 object print(d_25)

Calculating and displaying the difference between d and d_25 date_diff <- difftime(d_25, d, units= “days”)

Displaying the difference and checking if it is 25 days

print(daye_diff) print(date_diff == 25)