#“Introduction To Business Analytics with R”
d <- as.Date(“05/08/2020”, format = “%m/%d/%Y”)
print(d)
install.packages(“lubridate”)
library(lubridate)
d_year <- year(d) d_month <- month(d) d_week <- week(d) d_day <- wday(d)
print(d_year) print(d_month) print(d_week) print(d_day)
d_25 <- d + days(25) # Display the d_25 object print(d_25)
diff <- difftime(d_25, d, units = “days”) # Display the difference and check if it’s 25 days print(diff) print(diff == 25)