Skip to content
Justice Tech School

Dates and Regular Expressions

as.Date converts text to dates and format prints them. grepl, sub and gsub use regular expressions.

Example
d <- as.Date("2026-03-15")
print(format(d, "%d %B %Y")); print(d + 30)
print(grepl("^A", c("Ada", "Bob"))); print(gsub("[0-9]+", "#", "ab12cd345"))

Exercise

Convert to a date.

("2026-01-01")

Quiz Test

Which finds pattern matches as TRUE or FALSE?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.