Nothing
## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>")
## ----vector-------------------------------------------------------------------
library(timescapes)
x <- c(1, 1, 0, 0, 1, 1, 1, 0)
## ----plot-example-series------------------------------------------------------
plot(
seq_along(x), x,
type = "s",
ylim = c(-0.1, 1.1),
xlab = "Time step",
ylab = "Habitat available",
yaxt = "n",
main = "Binary habitat availability through time"
)
axis(2, at = c(0, 1), labels = c("No", "Yes"), las = 1)
## ----metrics------------------------------------------------------------------
ts_list_metrics()
ts_metric(x, "total_time")
ts_metric(x, "n_periods")
ts_metric(x, "gap_mean")
## ----core---------------------------------------------------------------------
ts_metric(x, "core_time_index", min_core_period = 3)
ts_metric(x, "n_core_periods", min_core_period = 3)
## ----missing------------------------------------------------------------------
ts_metric(c(1, 1, NA, 0), "n_periods")
## ----raster-------------------------------------------------------------------
library(terra)
r <- rast(nrows = 2, ncols = 2, nlyrs = 4)
values(r) <- matrix(
c(
1, 1, 0, 1,
0, 0, 0, 0,
1, 0, 1, 0,
1, 1, 1, 1
),
nrow = ncell(r),
byrow = TRUE
)
periods <- ts_raster_metric(r, "n_periods")
values(periods)
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.