Skip to content

Commit

Permalink
misc small changes
Browse files Browse the repository at this point in the history
  • Loading branch information
huizezhang-sherry committed Jun 26, 2023
1 parent c4df1b3 commit 9519ace
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
7 changes: 4 additions & 3 deletions R/as_cubble.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#' Coerce foreign objects into a cubble object
#' @param ... other arguments.
#' @param data an object to be converted into an cubble object.
#' @param data an object to be converted into an cubble object. Currently
#' support objects of classes `tibble`, `ncdf4`, `stars`, and `sftime`.
#' @param key a character (symbol), the spatial identifier,
#' see [cubble::make_cubble()].
#' see [cubble::make_cubble()]
#' @param index a character (symbol), the temporal identifier,
#' see [cubble::make_cubble()].
#' @param coords a vector of character (symbol) of length 2,
Expand Down Expand Up @@ -114,7 +115,7 @@ as_cubble.ncdf4 <- function(data, key, index, coords, vars,
# extract variables
lat_raw <- extract_longlat(data)$lat
long_raw <- extract_longlat(data)$long
time_raw <- extract_time(data)
time_raw <- extract_time(data) %>% as.Date()
var <- extract_var(data, vars)
lat_idx <- 1:length(lat_raw)
long_idx <- 1:length(long_raw)
Expand Down
6 changes: 4 additions & 2 deletions R/cubble-class.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
#'
#' @param ... a set of name-value pairs to create a cubble, need to include the
#' `key`, `index`, and `coords` variables.
#' @param key a character (or symbol), the spatial identifier.
#' @param key a character (or symbol), the spatial identifier. See the Key
#' section in [tsibble::as_tsibble()]
#' @param index a character (or symbol), the temporal identifier.
#' Currently support base R classes \code{Date}, \code{POSIXlt},
#' \code{POSIXct} and tsibble's [tsibble::yearmonth()], [tsibble::yearweek()],
#' and [tsibble::yearquarter()] class.
#' and [tsibble::yearquarter()] class. See the Index section in
#' [tsibble::as_tsibble()]
#' @param coords a vector of character (or symbol) of length two, in the order of
#' longitude first and then latitude, the argument can be omitted if created
#' from an sf and its subclasses. In case the sf geometry column is not POINT,
Expand Down
5 changes: 3 additions & 2 deletions man/as_cubble.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions man/cubble-class.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions man/dplyr.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions vignettes/cb3tsibblesf.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,10 @@ sf_nested %>% sf::st_transform(crs = "EPSG:3857")
The counterpart to promote the spatial component in an existing cubble to be an sf object is `make_spatial_sf()`:

```{r echo = TRUE}
sf_nested2 <- make_cubble(
(sf_nested2 <- make_cubble(
stations, meteo,
key = id, index = date, coords = c(long, lat)) %>%
make_spatial_sf()
all.equal(sf_nested2, sf_nested)
make_spatial_sf())
```

# Reference
2 changes: 1 addition & 1 deletion vignettes/cb5match.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ library(patchwork)
One common task when working with spatio-temporal data is to match nearby sites. For example, we may want to verify the location of an old list of stations with current stations, or we may want to match the data from different data sources. In this vignette, we will introduce the spatial and temporal matching in cubble using an example on matching river level data with precipitation in Victoria, Australia.


In cubble, spatial and tmeporal matching are performed using the functions `match_spatial()` and `match_temporal()`. The `match_spatial()` function calculates the spatial distance between observations in two cubble objects. Various distance measures are available (check `sf::st_distance`). Analysts can specify the number of matched groups to output using the `spatial_n_group` argument (default to 4 groups) and the number of matches per group using the `spatial_n_group`argument (default to 1, one-to-one matching). The syntax to use `match_spatial()` is:
In cubble, spatial and temporal matching are performed using the functions `match_spatial()` and `match_temporal()`. The `match_spatial()` function calculates the spatial distance between observations in two cubble objects. Various distance measures are available (check `sf::st_distance`). Analysts can specify the number of matched groups to output using the `spatial_n_group` argument (default to 4 groups) and the number of matches per group using the `spatial_n_group` argument (default to 1, one-to-one matching). The syntax to use `match_spatial()` is:

````
match_spatial(<cubble_obj1>, <cubble_obj2>, ...)
Expand Down

0 comments on commit 9519ace

Please sign in to comment.