Skip to content

Commit

Permalink
fix some typos in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
dramanica committed Nov 18, 2024
1 parent c2877c1 commit a9dbfd1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
8 changes: 4 additions & 4 deletions R/sample_background.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
#' (see details below).
#' @param raster the [terra::SpatRaster] or `stars` from which cells will be sampled (the first layer
#' will be used to determine which cells are NAs, and thus can not be sampled). If
#' sampling is "biased", then the sampling probability will be proportional to the values on
#' sampling is "bias", then the sampling probability will be proportional to the values on
#' the first layer (i.e. band) of the raster.
#' @param n number of background points to sample.
#' @param coords a vector of length two giving the names of the "x" and "y"
#' coordinates, as found in `data`. If left to NULL, the function will
#' try to guess the columns based on standard names `c("x", "y")`, `c("X","Y")`,
#' `c("longitude", "latitude")`, or `c("lon", "lat")`.
#' @param method sampling method. One of 'random', 'dist_max', and 'targeted'.
#' @param method sampling method. One of 'random', 'dist_max', and 'bias'.
#' For dist_max, the maximum distance is set as an additional element of a vector,
#' e.g c('dist_max',70000).
#' @param class_label the label given to the sampled points. Defaults to `background`
Expand Down Expand Up @@ -68,14 +68,14 @@ sample_background <- function(data, raster, n, coords = NULL,
}
dist_max <- as.numeric(method[2])
} else if (!method[1] %in% c("random", "bias")) {
stop("method has to be one of 'random', 'dist_min', 'dist_max', or 'dist_disc'")
stop("method has to be one of 'random', 'dist_max', or 'bias'")
}
xy_pres <- as.matrix(as.data.frame(data)[, coords])
# get a one layer raster
sampling_raster <- raster[[1]]
names(sampling_raster) <- "class"

# remove buffer >dist_max (or second parameter for disc)
# remove buffer >dist_max
if (!is.null(dist_max)) {
max_buffer <- terra::buffer(
terra::vect(xy_pres,
Expand Down
7 changes: 3 additions & 4 deletions R/sample_background_time.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Sample background points for SDM analysis for points with a time point.
#'
#' This function samples background points from a raster given a set of presences.
#' The locations returned as the center points of the sampled cells,, which can
#' The locations returned as the center points of the sampled cells, which can
#' overlap with the presences (in contrast to pseudo-absences, see
#' [sample_pseudoabs_time]). The following methods are implemented:
#' * 'random': background points randomly sampled from the region covered by the
Expand Down Expand Up @@ -31,8 +31,8 @@
#' @param time_col The name of the column with time; if time is not a lubridate object,
#' use `lubridate_fun` to provide a function that can be used to convert appropriately
#' @param lubridate_fun function to convert the time column into a lubridate object
#' @param method sampling method. One of 'random', 'dist_min', 'dist_max', or
#' 'dist_disc'.
#' @param method sampling method. One of 'random', 'dist_max', or
#' 'bias'.
#' @param class_label the label given to the sampled points. Defaults to `background`
#' @param return_pres return presences together with background
#' in a single tibble
Expand All @@ -56,7 +56,6 @@ sample_background_time <- function(data, raster, n_per_time_step, coords = NULL,
stop("'time_buffer' should only be set with method 'dist_max'")
}


# create a vector of times formatted as proper dates
time_lub <- data %>%
sf::st_drop_geometry() %>%
Expand Down
4 changes: 2 additions & 2 deletions man/sample_background.Rd

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

6 changes: 3 additions & 3 deletions man/sample_background_time.Rd

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

0 comments on commit a9dbfd1

Please sign in to comment.