Skip to content

Commit

Permalink
* Fix st_as_sftime.cubble() documentation.
Browse files Browse the repository at this point in the history
* Add installation info for `cubble` to DESCRIPTION to fix `pkgdown` GitHub actions workflow.
  • Loading branch information
henningte committed Jun 28, 2023
1 parent 214937e commit 423f39e
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ VignetteBuilder: knitr
RoxygenNote: 7.2.0
URL: https://r-spatial.github.io/sftime/, https://github.com/r-spatial/sftime
BugReports: https://github.com/r-spatial/sftime/issues/
Remotes: github::huizezhang-sherry/cubble
Collate:
sftime.R
init.R
Expand Down
5 changes: 3 additions & 2 deletions R/sftime.R
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ st_as_sftime.sftraj <- function(x, ...) {
}

#' @name st_as_sftime
#' @inheritParams cubble::add_geometry_column
#' @inheritParams cubble::make_spatial_sf
#' @examples
#' # convert a cubble_df object from package cubble to an sftime object
#' if (requireNamespace("cubble", quietly = TRUE, versionCheck = "0.3.0")) {
Expand All @@ -765,6 +765,7 @@ st_as_sftime.sftraj <- function(x, ...) {
#' # convert to sftime
#' climate_aus_sftime <-
#' st_as_sftime(climate_aus[1:4, ])
#'
#' climate_aus_sftime <-
#' st_as_sftime(cubble::face_temporal(climate_aus)[1:4, ])
#'
Expand All @@ -785,7 +786,7 @@ st_as_sftime.cubble_df <- function(x, ..., sfc = NULL, crs, silent = FALSE) {

# extract information needed to create the sftime object
time_column_name <- attr(x, which = "index")
id_column_name <- head(names(attr(x, "key")), -1)
id_column_name <- utils::head(names(attr(x, "key")), -1)
column_names <- c(setdiff(colnames(x), "ts"), colnames(x$ts[[1]]))
x_ts <- as.data.frame(cubble::face_temporal(x, col = "ts"))

Expand Down
3 changes: 2 additions & 1 deletion man/st_as_sftime.Rd

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

8 changes: 4 additions & 4 deletions vignettes/sftime.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ sftime supports coercion to `sftime` objects from the following classes (grouped
- spacetime: STI, STIDF
- trajectories: Track, Tracks, TracksCollection
- sftrack: sftrack, sftraj
<!-- - cubble: cubble_df-->
- cubble: cubble_df

**Conversion from `sf` objects:**

Expand Down Expand Up @@ -178,21 +178,21 @@ x2_Tracks_sftime <- st_as_sftime(x2_TracksCollection@tracksCollection[[1]])
x2_Track_sftime <- st_as_sftime(x2_TracksCollection@tracksCollection[[1]]@tracks[[1]])
```

<!--**Conversion from `cubble_df` objects**
**Conversion from `cubble_df` objects**

Both, nested and long-form `cubble_df` can be converted to class `sftime`. If the `cubble_df` object has no simple features column (is not also of class `sf`), the function first converts longitude and latitude to a simple features column using `cubble::add_geometry_column()`.

```{r, eval=FALSE, echo=FALSE}
```{r, eval=TRUE, echo=TRUE}
# get a sample cubble_df object
climate_aus <- cubble::climate_aus
# convert to sftime
climate_aus_sftime <-
st_as_sftime(climate_aus[1:4, ])
climate_aus_sftime <-
st_as_sftime(cubble::face_temporal(climate_aus)[1:4, ])
```
-->


## Subsetting
Expand Down

0 comments on commit 423f39e

Please sign in to comment.