lubridate
to Work with DatesToday we will…
Revisions are due by Friday
Any problem receiving a “Growing” can be revised and submitted for additional feedback
2008
and 2018
are not descriptive!
names_prefix =
argument to pivot_wider()
can help you make better column names!.groups = "drop"
within summarize()
your table still is grouped!
group_by()
+ summarize()
only drops the first group.group_by()
, then the data will still be grouped by the second variable!mc_toddler
– Aggregated weekly, full-time median price charged for Center-based Care for toddlers.mhi_2018
– Median household income expressed in 2018 dollars.DVS-2: I use plot modifications to make my visualizations clearer to the reader
DVS-3: I show creativity in my visualizations
"Accent"
palette from the RColorBrewer package, but you might like others!colorRampPalette()
function to get more colors.theme_bw()
, but you might like others!I strongly recommend against nested functions, as they are difficult for people to understand what your code is doing. Having two lines is not less efficient and is more readable.
Make sure your feedback follows the code review guidelines.
Insert your review into the comment box!
You will create a Midterm Portfolio, with code covering the learning targets we have covered thus far in the course.
Follow these directions to fork a copy of the Final Portfolio repository.
Clone the repository into RStudio.
Open the reflection_template.qmd
file and give it a read!
Start finding excerpts of code you wrote for the Labs or Challenges that fit each learning target.
When parsing dates and times, we have to consider complicating factors like…
lubridate
Convert a date-like variable (“May 8, 1995”) to a date or date-time object.
Find the weekday, month, year, etc from a date-time object.
Convert between time zones.
Note
The lubridate
package installs and loads with the tidyverse
.
date-time
ObjectsThere are multiple data types for dates and times.
date
or Date
dtm
POSIXlt
– stores date-times as the number of seconds since January 1, 1970 (“Unix Epoch”)POSIXct
– stores date-times as a list with elements for second, minute, hour, day, month, year, etc.date-time
ObjectsCreate a date from individual components:
date-time
Object from a Stringdate-time
ObjectsWhat’s wrong here?
Make sure you use quotes!
date-time
Componentsdate-time
ObjectsDoing subtraction gives you a difftime
object.
difftime
objects do not always have the same units – it depends on the scale of the objects you are working with.
We can also add time to date-time
objects:
days()
, years()
, etc. will add a period of time.ddays()
, dyears()
, etc. will add a duration of time.…are complicated!
Specify time zones in the form:
You can change the time zone of a date in two ways:
with_tz()
When you read data in or create a new date-time object, the default time zone (if not specified) is UTC (Universal Time Coordinated)*.
None of us have all these abilities. Each of us has some of these abilities.
Every group should have a lubridate cheatsheet!
On the Front:
On the Back:
Every group should have a task card!
On the Front
On the Back
lubridate
functions for different tasks you may encounterThe partner who got the most sleep starts as the Developer (typing and listening to instructions from the Coder)!
Submit the name of the thief to the Canvas Quiz.
PA-5-dates.html
file for the group.