Skip to content

Commit

Permalink
slight tweak on vig
Browse files Browse the repository at this point in the history
  • Loading branch information
huizezhang-sherry committed Nov 7, 2022
1 parent dae99df commit ccfbbe8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
13 changes: 5 additions & 8 deletions vignettes/aggregation.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ title: "Aggregating data spatially, and making glyph maps"
output: rmarkdown::html_vignette
vignette: >
%\VignetteIndexEntry{aggregation}
%\VignetteEngine{knitr::rmarkdown}
%\usepackage[utf8]{inputenc}
%\VignetteEngine{knitr::rmarkdown}
editor_options:
chunk_output_type: console
---

```{r, include = FALSE}
Expand Down Expand Up @@ -37,11 +39,7 @@ This is a lot of stations to look at for one climate variable and they can't all
First, let's summarise the daily data into weekly sum for each station:

```{r}
(station_long <- prcp_aus %>%
face_temporal(ts) %>%
mutate(wk = lubridate::week(date)) %>%
group_by(wk) %>%
summarise(prcp = sum(prcp, na.rm = TRUE)))
prcp_aus
```

First we need to assign each station a cluster number. Here we use a simple kmean algorithm based on the distance matrix to create 20 clusters. This creates `station_nested` as a station level nested cubble with a cluster column indicating the group each station belongs to.
Expand All @@ -51,8 +49,7 @@ coords <- cbind(prcp_aus$long, prcp_aus$lat)
dist_raw <- geosphere::distm(coords, coords)
set.seed(123)
station_nested <- station_long %>%
face_spatial() %>%
station_nested <- prcp_aus %>%
strip_rowwise() %>%
mutate(cluster = kmeans(dist_raw,centers = 20, nstart = 500)$cluster)
```
Expand Down
4 changes: 2 additions & 2 deletions vignettes/matching.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Again we will start with `prcp_aus` to look at precipitation and focus on New So
nsw_map <- ozmaps::abs_ste %>%
filter(NAME == "New South Wales")
nsw <- prcp_aus %>%
nsw <- climate_aus %>%
# subset for New South Wales stations
filter(between(as.numeric(stringr::str_sub(id, 7, 8)), 46, 75)) %>%
mutate(automated = stringr::str_detect(name, "aws")) %>%
Expand Down Expand Up @@ -128,7 +128,7 @@ Bureau of Meteorology collects [water data](http://www.bom.gov.au/metadata/catal
```{r echo = FALSE}
river <- river %>% mutate(type = "river")
vic <- prcp_aus %>%
vic <- climate_aus %>%
# subset for Victoria stations
filter(between(as.numeric(stringr::str_sub(id, 7, 8)), 76, 90)) %>%
face_temporal() %>%
Expand Down

0 comments on commit ccfbbe8

Please sign in to comment.