mod3_peer_review_Harsh_choubey.RMD

Author

Harsh choubey

Introduction to Business Analytics with R

Quarto

Quarto enables you to weave together content and executable code into a finished document. To learn more about Quarto see https://quarto.org.

Running Code

When you click the Render button a document will be generated that includes both content and the output of embedded code. You can embed code like this:

1 + 1
[1] 2
# Create a datetime object from the character string
d <- as.Date("05/08/2020", format = "%m/%d/%Y")
d
[1] "2020-05-08"
# Check the data type of the datetime object
typeof(d)
[1] "double"
# Install lubridate package if necessary
if (!require(lubridate)) {
  install.packages("lubridate")
}
Loading required package: lubridate

Attaching package: 'lubridate'
The following objects are masked from 'package:base':

    date, intersect, setdiff, union
# Load the lubridate package
library(lubridate)

# Extract year, month number, week number, and weekday number
d_year <- year(d)
d_month <- month(d)
d_week <- week(d)
d_day <- wday(d)

# Display the extracted values
d_year
[1] 2020
d_month
[1] 5
d_week
[1] 19
d_day
[1] 6
# Create a datetime object for 25 days from the original date
d_25 <- d + days(25)
d_25
[1] "2020-06-02"
# Calculate the difference between d and d_25
diff <- difftime(d_25, d, units = "days")

# Display the difference
diff
Time difference of 25 days

You can add options to executable code like this

[1] 4

The echo: false option disables the printing of code (only output is displayed).