man-roxygen/class_geocontainer_accessors.R

# class_geocontainer_accessors.R


#' @name GeoContainer-accessors
#'
#' @title
#' GeoContainer: get or set slots
#'
#' @description
#' Get or set the values stored in slots of an object of class
#' [`GeoContainer`][GeoContainer-class].
#'
#' @param x conceptually, any \R object.
#' @param value depends of the function used.
#' * For [`xcol<-()`] and [`ycol<-()`], a character of length 1.
#' * For [`crs<-()`], a numeric value of length 1 that can be parsed to an
#' integer or an object of class [`sp::CRS`][sp::CRS-class].
#' @param simplify a logical. If `TRUE`, the output is coerced to a numeric
#' matrix. Else, a [`data.table`][data.table::data.table()] is returned.
#' @param ... further arguments passed to or from methods.
#'
#' @return
#' [xcol()] and [ycol()] return a character of length 1.
#'
#' [crs()] returns an object of class [`sp::CRS`][sp::CRS-class].
#'
#' [xy()] returns a numeric matrix if `simplify` is `TRUE` and a
#' [`data.table`][data.table::data.table()] if `simplify` is `FALSE`. Both
#' outputs have two columns named after slots `xcol` and `ycol`.
#'
#' Functions [`xcol<-()`][xcol()], [`ycol<-()`][ycol()] and [`crs<-()`][crs()]
#' update `x` and return its updated version invisibly.
#'
#' @details
#' Functions [`xcol<-()`][xcol()] and [`ycol<-()`][ycol()] update the underlying
#' column names of slot `table` *by reference* through a call to
#' [setnames()][data.table::setattr()].
#'
#' ## The [xy()] accessor function
#'
#' The [xy()] function extracts spatial coordinates from an object of class
#' [`GeoContainer`][GeoContainer-class]. Indeed, `xy` is not a formal slot, but
#' it is defined here for convenience because it is closely related to slots
#' `xcol` and `ycol`.
#'
#' @family GeoContainer
jeanmathieupotvin/cargo documentation built on Oct. 27, 2020, 5:22 p.m.