|
4 | 4 | #' outliers and spatial outliers or local defective observations. Default |
5 | 5 | #' values are optimized for precision agricultural data. |
6 | 6 | #' |
7 | | -#' @inheritParams remove_border |
8 | | -#' @inheritParams remove_outlier |
9 | | -#'@inheritParams remove_inlier |
| 7 | +#' @param x an \code{sf} points object |
| 8 | +#' @param y \code{character} with the name of the variable to use for |
| 9 | +#' depuration/filtering process |
10 | 10 | #' @param toremove \code{character} vector specifying the procedure to |
11 | 11 | #' implement for errors removal. Default 'edges', 'outlier', 'inlier'. |
12 | 12 | #' See Details. |
| 13 | +#' @param crs coordinate reference system: integer with the EPSG code, |
| 14 | +#' or character with proj4string to convert coordinates if \code{x} has |
| 15 | +#' longitude/latitude data |
| 16 | +#' @param buffer \code{numeric} distance in meters to be removed. Negative |
| 17 | +#' values are recommended |
| 18 | +#' @param ylimitmax \code{numeric} of length 1 indicating the maximum limit |
| 19 | +#' for the \code{y} variable. If \code{NA} \code{Inf} is assumed |
| 20 | +#' @param ylimitmin \code{numeric} of length 1 indicating the minimum limit |
| 21 | +#' for the \code{y} variable. If \code{NA} \code{-Inf} is assumed |
| 22 | +#' @param sdout \code{numeric} values outside the interval |
| 23 | +#' \eqn{mean ± sdout × sdout} values will be removed |
| 24 | +#' @param ldist \code{numeric} lower distance bound to identify neighbors |
| 25 | +#' @param udist \code{numeric} upper distance bound to identify neighbors |
| 26 | +#' @param criteria \code{character} with "LM" and/or "MP" for methods to |
| 27 | +#' identify spatial outliers |
| 28 | +#' @param zero.policy default NULL, use global option value; |
| 29 | +#' if FALSE stop with error for any empty neighbors sets, |
| 30 | +#' if TRUE permit the weights list to be formed with zero-length |
| 31 | +#' weights vectors |
| 32 | +#' @param poly_border \code{sf} object with one polygon or NULL. Can be |
| 33 | +#' the result of \code{concaveman::concaveman} |
13 | 34 | #' |
14 | 35 | #' @details |
15 | 36 | #' Possible values for \code{toremove} are one or more elements of: |
|
26 | 47 | #' automating error removal from yield maps. Precision Agric 20, 1030–1044 |
27 | 48 | #' (2019). https://doi.org/10.1007/s11119-018-09632-8 |
28 | 49 | #' |
29 | | -#' @return an object of class \code{paar} |
| 50 | +#' @return an object of class \code{paar} with two elements: |
| 51 | +#' \describe{ |
| 52 | +#' \item{depurated_data}{\code{sf} object with the data after the removal |
| 53 | +#' process} |
| 54 | +#' \item{condition}{\code{character} vector with the condition of each |
| 55 | +#' observation} |
| 56 | +#' } |
30 | 57 | #' @export |
31 | 58 | #' @example inst/examples/depurate.R |
32 | 59 |
|
@@ -141,7 +168,8 @@ depurate <- function(x, |
141 | 168 | #' values are recommended |
142 | 169 | #' @param poly_border \code{sf} object with one polygon or NULL. Can be |
143 | 170 | #' the result of \code{concaveman::concaveman} |
144 | | -#' |
| 171 | +#' @noRd |
| 172 | +#' @keywords internal |
145 | 173 | remove_border<-function(x, |
146 | 174 | crs=NULL, |
147 | 175 | buffer, |
@@ -282,8 +310,8 @@ remove_border <- function(x, |
282 | 310 | #' for the \code{y} variable. If \code{NA} \code{-Inf} is assumed |
283 | 311 | #' @param sdout \code{numeric} values outside the interval |
284 | 312 | #' \eqn{mean ± sdout × sdout} values will be removed |
285 | | -#' |
286 | | -#' |
| 313 | +#' @noRd |
| 314 | +#' @keywords internal |
287 | 315 | remove_outlier<-function(x, |
288 | 316 | y, |
289 | 317 | ylimitmax=NA, |
@@ -351,7 +379,8 @@ remove_outlier <- function(x, |
351 | 379 | #' if FALSE stop with error for any empty neighbors sets, |
352 | 380 | #' if TRUE permit the weights list to be formed with zero-length |
353 | 381 | #' weights vectors |
354 | | -#' |
| 382 | +#' @noRd |
| 383 | +#' @keywords internal |
355 | 384 | remove_inlier<-function(x, |
356 | 385 | y, |
357 | 386 | ldist=0, |
@@ -442,6 +471,7 @@ remove_inlier <- function(x, |
442 | 471 | #' @param is_error internal object |
443 | 472 | #' @param remove_result internal results from remove_* functions |
444 | 473 | #' @noRd |
| 474 | +#' @keywords internal |
445 | 475 | is_error_update<-function(is_error,remove_result) { |
446 | 476 | # Keeps NA, others are conditions |
447 | 477 | is_error_no_na<-is_error[is.na(is_error$because),] |
|