Skip to content

Commit

Permalink
try fewer years for vignette
Browse files Browse the repository at this point in the history
- sometimes stalls on gha when new years of NARR data are downloaded
  • Loading branch information
cole-brokamp committed Mar 19, 2024
1 parent 73c738c commit c610c14
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 2 additions & 3 deletions vignettes/case-crossover-example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ library(appc)
library(dplyr, warn.conflicts = FALSE)
```

This example details how to use the appc package to add air pollution exposure estimates for exact locations and dates defined by geocoded coordinates and a case date. For this example workflow, we will simulate 20 random locations in Wayne County, Michigan and case dates between 2019 and 2022, but in actuality this can be any set of geocoded `lat` and `lon` columns with corresponding dates.
This example details how to use the appc package to add air pollution exposure estimates for exact locations and dates defined by geocoded coordinates and a case date. For this example workflow, we will simulate 20 random locations in Wayne County, Michigan and case dates in 2022, but in actuality this can be any set of geocoded `lat` and `lon` columns with corresponding dates.

```{r}
#| warnings: false
Expand All @@ -34,7 +34,7 @@ d <-
sf::st_coordinates() |>
tibble::as_tibble() |>
rename(lat = Y, lon = X) |>
mutate(case_date = sample(seq(as.Date("2019-01-01"), as.Date("2022-12-31"), by = 1), size = 20)) |>
mutate(case_date = sample(seq(as.Date("2022-01-01"), as.Date("2022-12-31"), by = 1), size = 20)) |>
mutate(id = 1:20) |>
relocate(id)
Expand Down Expand Up @@ -75,7 +75,6 @@ Then we can directly use the `s2` and `dates` columns to add temperature and hum
d <- d |> dplyr::mutate(temperature = get_narr_data(s2, dates, "air.2m"),
humidity = get_narr_data(s2, dates, "rhum.2m"))
d <- d |> dplyr::mutate(pm25 = predict_pm25(s2, dates))
d
Expand Down
6 changes: 6 additions & 0 deletions vignettes/timeline-example.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,24 @@ d <- d |>
rowwise() |>
mutate(dates = list(seq(start_date, end_date, by = 1))) |>
ungroup()
d
```

Next, we will use the `lon` and `lat` columns to create the s2 geohash:

```{r}
d <- d |> dplyr::mutate(s2 = s2::as_s2_cell(s2::s2_geog_point(lon, lat)))
d
```

Directly use the `s2` and `dates` columns to call the `predict_pm25()` function:

```{r}
d <- d |> dplyr::mutate(pm25 = predict_pm25(s2, dates))
d
```

With daily exposures, we could average fine particulate matter throughout the study period:
Expand Down

0 comments on commit c610c14

Please sign in to comment.