Outputting pretty dates and times
An easy way to output dates is to use the stamp()
function in lubridate
. stamp()
takes a string which should be an example of how the date should be formatted, and returns a function that can be used to format dates.
In this exercise you'll practice outputting today()
in a nice way.
Diese Übung ist Teil des Kurses
Working with Dates and Times in R
Anleitung zur Übung
- Create a
stamp()
based on the string"Saturday, Jan 1, 2000"
. - Print
date_stamp
. Notice it is a function. - Pass
today()
todate_stamp
to format today's date. - Now output today's date in American style
MM/DD/YYYY
. - Finally, use stamp based on the
finished
string I've put in your workspace to formattoday()
.
Interaktive Übung
Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.
# Create a stamp based on "Saturday, Jan 1, 2000"
date_stamp <- stamp(___)
# Print date_stamp
# Call date_stamp on today()
___(today())
# Create and call a stamp based on "12/31/1999"
stamp(___)(today())
# Use string finished for stamp()
stamp(___)(today())