This vignette documents miscellaneous examples and questions received
regarding the cubble
package.
Q: I’m trying to summarise the average maximum temperature by station. I’m not sure why the summarise function is not returning a temporal object.
climate_mel |>
face_temporal() |>
summarise(tmax_avg = mean(tmax, na.rm=TRUE))
#> # A tibble: 3 × 2
#> id tmax_avg
#> <chr> <dbl>
#> 1 ASN00086038 26.5
#> 2 ASN00086077 25.7
#> 3 ASN00086282 26.6
A: This operation should be performed in the spatial form. The form to use for an operation depends on the structure of the result. If the result has each key in a row without temporal index, it should be operated in the spatial form (example here):
climate_mel |>
rowwise() |>
mutate(tmax_avg = mean(ts$tmax, na.rm=TRUE))
#> # cubble: key: id [3], index: date, nested form
#> # spatial: [144.83, -37.98, 145.1, -37.67], Missing CRS!
#> # temporal: date [date], prcp [dbl], tmax [dbl], tmin [dbl]
#> id long lat elev name wmo_id ts tmax_avg
#> <chr> <dbl> <dbl> <dbl> <chr> <dbl> <list> <dbl>
#> 1 ASN00086038 145. -37.7 78.4 essendon airport 95866 <tibble> 26.5
#> 2 ASN00086077 145. -38.0 12.1 moorabbin airport 94870 <tibble> 25.7
#> 3 ASN00086282 145. -37.7 113. melbourne airport 94866 <tibble> 26.6