# >
Dates and times
For these exercises, we’ll use the dates data set.
- Load tidyverse, import
dates.csv
todates
, and view the data set.
- Convert
birth_date
to a date object and resavedates
.
# >
- Create a column called time1 that converts test1 to datetime and change the time zone to “America/Chicago”.
# >
- Calculate each participant’s age in years at the time of test 1, rounded to 1 decimal place, stored in age and resave
dates
.
# >
- Calculate the number of days between test 1 and test 2 for each participant and label this column test_diff (and resave
dates
).
# >
- Create
dates2
that subsets the participants who were born after January 1, 1970.
# >
- Create a column named diff_text that writes the following sentence for each participant in
dates2
: “Participant [insert id] (age: [insert age]) had test 1 on [insert test1] and test 2 on [insert test2], which were [insert test_diff] days apart.”
# >