# Step 1: Get the current date
current_date <- Sys.Date()
# Step 2: Extract the year and month from the current date
year <- as.integer(format(current_date, "%Y"))
month <- as.integer(format(current_date, "%m"))
# Step 3: Calculate the first day of the current month
first_day_of_current_month <- as.Date(paste(year, month, "01", sep = "-"))
# Step 4: Subtract one day to get the last day of the previous month
last_day_of_previous_month <- first_day_of_current_month - 1
# Step 5: Print the result
print(last_day_of_previous_month)