# Example 1: Date of a weekend
weekend(as.Date("2025-01-18"))
# Example 2: Date of a weekday
weekend(as.Date("2025-01-15"))
# Example 3: Date of an invalid object
try(
weekend("2025-01-18") # This will throw an error
)
Run the code above in your browser using DataLab