---
title: "Dates and times"
author: "Jeffrey R. Stevens"
date: "2023-03-22"
output: html_document
execute:
  freeze: true
---

For these exercises, we'll use the dates data set. 


1. Load tidyverse, import [`dates.csv`](https://jeffreyrstevens.quarto.pub/dpavir/data/dates.csv) to `dates`, and view the data set.

```{r}
# >
```


2. Convert `birth_date` to a date object and resave `dates`.

```{r}
# >
```


3. Create a column called _time1_ that converts _test1_ to datetime and change the time zone to "America/Chicago".

```{r}
# >
```


4. Calculate each participant's age in years at the time of test 1, rounded to 1 decimal place, stored in _age_ and resave `dates`.

```{r}
# >
```


5. Calculate the number of days between test 1 and test 2 for each participant and label this column _test_diff_ (and resave `dates`).

```{r}
# >
```


6. Create `dates2` that subsets the participants who were born after January 1, 1970.

```{r}
# >
```


7. 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."

```{r}
# >
```

