diff --git a/.github/workflows/Deploy-pkgdown.yaml b/.github/workflows/Deploy-pkgdown.yaml index 5c8d0f2..eddaa7f 100644 --- a/.github/workflows/Deploy-pkgdown.yaml +++ b/.github/workflows/Deploy-pkgdown.yaml @@ -3,7 +3,7 @@ on: push: - branches: [main, development] + branches: [main, dev] tags: ['*'] workflow_dispatch: diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 43b1919..3021559 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -3,7 +3,7 @@ on: push: - branches: [main, development] + branches: [main, dev] pull_request: branches: [main] workflow_dispatch: diff --git a/.github/workflows/Render-README.yaml b/.github/workflows/Render-README.yaml index 54f3be2..0961afe 100644 --- a/.github/workflows/Render-README.yaml +++ b/.github/workflows/Render-README.yaml @@ -3,7 +3,7 @@ on: push: - branches: [main, development] + branches: [main, dev] paths: ["README.Rmd"] workflow_dispatch: diff --git a/.github/workflows/Test-coverage.yaml b/.github/workflows/Test-coverage.yaml index eea1bd6..84eb789 100644 --- a/.github/workflows/Test-coverage.yaml +++ b/.github/workflows/Test-coverage.yaml @@ -3,7 +3,7 @@ on: push: - branches: [main, development] + branches: [main, dev] pull_request: branches: [main] workflow_dispatch: diff --git a/.gitignore b/.gitignore index 075f0a8..8735097 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ .Ruserdata docs CRAN-SUBMISSION +.DS_Store diff --git a/DESCRIPTION b/DESCRIPTION index 25345f9..bc6e696 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Type: Package Package: onpoint Title: Helper Functions for Point Pattern Analysis -Version: 1.0.6 +Version: 1.1 Authors@R: person("Maximilian H.K.", "Hesselbarth", email = "mhk.hesselbarth@gmail.com", diff --git a/NAMESPACE b/NAMESPACE index 32204ff..3430975 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,12 +2,12 @@ S3method(plot,env_summarized) S3method(print,env_summarized) +export(Oest) export(balance_points) -export(center_l_function) -export(estimate_o_ring) -export(estimate_pcf_fast) +export(center_Lest) +export(pcf_fast) export(plot_quantums) +export(rheteroppp) export(rlabel_local) -export(simulate_antecedent_conditions) -export(simulate_heterogenous_pattern) +export(simulate_antecedent) export(summarize_envelope) diff --git a/NEWS.md b/NEWS.md index f5bffe7..6f10496 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +# onpoint 1.1 +* Improved function names + # onpoint 1.0.6 * Order of stable `i` and randomized pattern `j` changed in `simulate_antecedent_conditions` * Fix anchors in documentation diff --git a/R/estimate_o_ring.R b/R/Oest.R similarity index 94% rename from R/estimate_o_ring.R rename to R/Oest.R index 0bc6c31..67558b0 100644 --- a/R/estimate_o_ring.R +++ b/R/Oest.R @@ -1,4 +1,4 @@ -#' estimate_o_ring +#' Oest #' #' @description O-ring function #' @@ -26,7 +26,7 @@ #' #' @examples #' input_pattern <- spatstat.random::runifpoint(n = 100) -#' estimate_o_ring(input_pattern) +#' Oest(input_pattern) #' #' @references #' Wiegand, T., Moloney, K.A., 2004. Rings, circles, and null models for point pattern @@ -36,7 +36,7 @@ #' ecology. Chapman and Hall/CRC Press, Boca Raton, USA. #' #' @export -estimate_o_ring <- function(x, ...) { +Oest <- function(x, ...) { if (!spatstat.geom::is.ppp(x)) { stop("Please provide ppp.") diff --git a/R/balance_points.R b/R/balance-points.R similarity index 97% rename from R/balance_points.R rename to R/balance-points.R index f443943..e3aa358 100644 --- a/R/balance_points.R +++ b/R/balance-points.R @@ -8,8 +8,8 @@ #' #' @details #' The function balances out the number of points in the input pattern to either -#' the provided number of points as integer or the same number of points if a \code{ppp} -#' object is provided. +#' the provided number of points as integer or the same number of points if a +#' \code{ppp} object is provided. #' #' @return ppp #' diff --git a/R/calc_area.R b/R/calc-area.R similarity index 100% rename from R/calc_area.R rename to R/calc-area.R diff --git a/R/center_l_function.R b/R/center-Lest.R similarity index 91% rename from R/center_l_function.R rename to R/center-Lest.R index 2ecee8f..b23415d 100644 --- a/R/center_l_function.R +++ b/R/center-Lest.R @@ -1,4 +1,4 @@ -#' center_l_function +#' center_Lest #' #' @description Centered L-function #' @@ -18,10 +18,10 @@ #' #' @examples #' input_pattern <- spatstat.random::runifpoint(n = 100) -#' center_l_function(input_pattern, correction = "Ripley") +#' center_Lest(input_pattern, correction = "Ripley") #' #' lest <- spatstat.explore::Lest(input_pattern) -#' center_l_function(lest) +#' center_Lest(lest) #' #' @references #' Besag, J.E., 1977. Discussion on Dr. Ripley’s paper. Journal of the Royal Statistical @@ -36,7 +36,7 @@ #' #' #' @export -center_l_function <- function(x, ...) { +center_Lest <- function(x, ...) { if (!spatstat.geom::is.ppp(x) && !spatstat.geom::is.fv(x)) { stop("Please provide either ppp or fv object.") diff --git a/R/estimate_pcf_fast.R b/R/pcf-fast.R similarity index 92% rename from R/estimate_pcf_fast.R rename to R/pcf-fast.R index 4e8d610..6494aad 100644 --- a/R/estimate_pcf_fast.R +++ b/R/pcf-fast.R @@ -1,4 +1,4 @@ -#' estimate_pcf_fast +#' pcf_fast #' #' @description Fast estimation of the pair correlation function #' @@ -22,7 +22,7 @@ #' @examples #' set.seed(42) #' pattern <- spatstat.random::runifpoint(n = 100) -#' pcf_fast <- estimate_pcf_fast(pattern) +#' pcf_fast <- pcf_fast(pattern) #' #' @references #' Ripley, B.D., 1977. Modelling spatial patterns. Journal of the Royal Statistical Society. @@ -32,7 +32,7 @@ #' John Wiley & Sons, Chichester, UK. #' #' @export -estimate_pcf_fast <- function(pattern, ...){ +pcf_fast <- function(pattern, ...){ k_fun <- suppressMessages(spatstat.explore::Kest(X = pattern, ...)) # estimate K-fct diff --git a/R/plot_quantums.R b/R/plot-quantums.R similarity index 100% rename from R/plot_quantums.R rename to R/plot-quantums.R diff --git a/R/simulate_heterogenous_pattern.R b/R/rheteroppp.R similarity index 91% rename from R/simulate_heterogenous_pattern.R rename to R/rheteroppp.R index e1b4ec8..16a4342 100644 --- a/R/simulate_heterogenous_pattern.R +++ b/R/rheteroppp.R @@ -1,4 +1,4 @@ -#' simulate_heterogenous_pattern +#' rheteroppp #' #' @description Simulate heterogeneous pattern #' @@ -23,7 +23,7 @@ #' @examples #' set.seed(42) #' input_pattern <- spatstat.random::rpoispp(lambda = function(x , y) {100 * exp(-3 * x)}, nsim = 1) -#' null_model <- simulate_heterogenous_pattern(input_pattern, nsim = 19) +#' null_model <- rheteroppp(input_pattern, nsim = 19) #' spatstat.explore::envelope(Y = input_pattern, fun = spatstat.explore::pcf, nsim = 19, #' simulate = null_model) #' @@ -35,7 +35,7 @@ #' ecology. Chapman and Hall/CRC Press, Boca Raton, USA. #' #' @export -simulate_heterogenous_pattern <- function(x, nsim, fix_n = FALSE, ...) { +rheteroppp <- function(x, nsim, fix_n = FALSE, ...) { if (!inherits(x = x, what = "ppp")) { stop("Please provide ppp object.", call. = FALSE) diff --git a/R/rlabel_local.R b/R/rlabel-local.R similarity index 100% rename from R/rlabel_local.R rename to R/rlabel-local.R diff --git a/R/simulate_antecedent_conditions.R b/R/simulate-antecedent.R similarity index 94% rename from R/simulate_antecedent_conditions.R rename to R/simulate-antecedent.R index b54156e..e975ff0 100644 --- a/R/simulate_antecedent_conditions.R +++ b/R/simulate-antecedent.R @@ -1,4 +1,4 @@ -#' simulate_antecedent_conditions +#' simulate_antecedent #' #' @description Simulate heterogenous pattern #' @@ -33,7 +33,7 @@ #' spatstat.geom::marks(pattern_b) <- "b" #' pattern <- spatstat.geom::superimpose(pattern_a, pattern_b) #' -#' null_model <- simulate_antecedent_conditions(x = pattern, i = "a", j = "b", nsim = 19) +#' null_model <- simulate_antecedent(x = pattern, i = "a", j = "b", nsim = 19) #' spatstat.explore::envelope(Y = pattern, fun = spatstat.explore::pcf, #' nsim = 19, simulate = null_model) #' @@ -46,7 +46,7 @@ #' ecology. Chapman and Hall/CRC Press, Boca Raton, USA. #' #' @export -simulate_antecedent_conditions <- function(x, i, j, nsim, heterogenous = FALSE, ...) { +simulate_antecedent <- function(x, i, j, nsim, heterogenous = FALSE, ...) { # check if pattern ist marked if (!spatstat.geom::is.marked(x)) { diff --git a/R/split_at.R b/R/split-at.R similarity index 100% rename from R/split_at.R rename to R/split-at.R diff --git a/R/summarize_envelope.R b/R/summarize-envelope.R similarity index 100% rename from R/summarize_envelope.R rename to R/summarize-envelope.R diff --git a/README.Rmd b/README.Rmd index e24bde5..99027f4 100644 --- a/README.Rmd +++ b/README.Rmd @@ -58,15 +58,14 @@ data(spruces) Currently, `onpoint` provides three second-order summary functions, namely Besag's L-function centered to zero and the O-ring statistic and a fast estimation of the pair-correlation function. -Centering Besag's L-function to zero has the advantage of an easier interpretation and plotting (Haase 1995). The function `center_l_function()` can either deal with a point pattern and calculated the centered L-function directly, or center the L-function afterwards it was calculating using `spatstat`s `Lest()`. +Centering Besag's L-function to zero has the advantage of an easier interpretation and plotting (Haase 1995). The function `center_Lest()` can either deal with a point pattern and calculated the centered L-function directly, or center the L-function afterwards it was calculating using `spatstat`s `Lest()`. ```{r calc_lfun} # calculate L-function l_function <- Lest(spruces, correction = "Ripley") # center L-function to zero -# center_l_function <- center_l_function(l_function) -l_function_centered <- center_l_function(spruces, correction = "Ripley") +l_function_centered <- center_Lest(spruces, correction = "Ripley") ``` ```{r plot_lfun, echo = FALSE, fig.width = 10, fig.height = 5, fig.align = "center"} @@ -76,10 +75,10 @@ plot(l_function_centered, main = "centered Besag's L-function") par(mfrow = c(1, 1)) ``` -The O-ring statistic O(r) (Wiegand & Moloney 2004) can be calculated using `estimate_o_ring()`. Generally speaking, O(r) scales the pair correlation g(r) function with help of the intensity \eqn{\lambda}. One advantage of the O-ring statistic is that it can be interpreted as a neighborhood density because it is a probability density function (Wiegand & Moloney 2004). +The O-ring statistic O(r) (Wiegand & Moloney 2004) can be calculated using `Oest()`. Generally speaking, O(r) scales the pair correlation g(r) function with help of the intensity \eqn{\lambda}. One advantage of the O-ring statistic is that it can be interpreted as a neighborhood density because it is a probability density function (Wiegand & Moloney 2004). ```{r calc_oring} -o_ring <- estimate_o_ring(spruces) +o_ring <- Oest(spruces) ``` Of course, both summary functions can be used in combination with `spatstat`'s `envelope()` function. @@ -92,20 +91,20 @@ oring_envelope <- envelope(spruces, fun = estimate_o_ring, nsim = 199, verbose = plot(oring_envelope, main = "O-ring statistic") ``` -`estimate_pcf_fast()` estimates the pair-correlation function based on Ripley's K-function, which is faster than estimation the pair-correlation function directly. +`pcf_fast()` estimates the pair-correlation function based on Ripley's K-function, which is faster than estimation the pair-correlation function directly. ```{r calc_fast, collapse = TRUE} -estimate_pcf_fast(spruces) +pcf_fast(spruces) ``` ### Null models `onpoint` includes two functions to simulate null model patterns. -`simulate_heterogenous_pattern()` is a convienent wrapper around a few `spatstat` functions to straighforward simulate a heterogeneous Poisson process. +`rheteroppp()` is a convienent wrapper around a few `spatstat` functions to straighforward simulate a heterogeneous Poisson process. ```{r calc_hetero} -null_model_hetero <- simulate_heterogenous_pattern(spruces, nsim = 199) +null_model_hetero <- rheteroppp(spruces, nsim = 199) hetero <- envelope(spruces, fun = pcf, funargs = list(correction = "Ripley", divisor = "d"), @@ -117,13 +116,13 @@ hetero <- envelope(spruces, fun = pcf, plot(hetero, main = "Heterogeneous Poisson process") ``` -To simulate antecedent conditions in which only one pattern influences the other, but not the other way around (Wiegand & Moloney 2004, Velazquez et al. 2016), `simulate_antecedent_conditions()` can be used. This null model randomizes only one type of points (e.g. seedlings), while keeping the other type of points constant (e.g. mature trees) to check for associations between the two. +To simulate antecedent conditions in which only one pattern influences the other, but not the other way around (Wiegand & Moloney 2004, Velazquez et al. 2016), `simulate_antecedent()` can be used. This null model randomizes only one type of points (e.g. seedlings), while keeping the other type of points constant (e.g. mature trees) to check for associations between the two. ```{r calc_antecedent} marks(spruces) <- ifelse(marks(spruces) > 0.3, yes = "adult", no = "seedling") -null_model_antecedent <- simulate_antecedent_conditions(spruces, - i = "seedling", j = "adult", nsim = 199) +null_model_antecedent <- simulate_antecedent(spruces, i = "seedling", j = "adult", + nsim = 199) antecedent <- envelope(spruces, fun = pcf, funargs = list(correction = "Ripley", divisor = "d"), @@ -137,7 +136,7 @@ plot(antecedent, main = "Antecedent conditions") ### Various -To plot simulation envelopes using quantum plots (e.g. Esser et al. 2015), just pass an `envelope` object as input to `plot_quantums()`. +To plot simulation envelopes using quantum plots (e.g., Esser et al. 2015), just pass an `envelope` object as input to `plot_quantums()`. ```{r plot_quantums, fig.width = 7.5, fig.height = 5, fig.align = "center"} plot_quantums(antecedent, ylab = "g(r)") diff --git a/_pkgdown.yml b/_pkgdown.yml index 62267e0..8f9214d 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -7,16 +7,16 @@ template: reference: - title: Summary functions contents: - - center_l_function - - estimate_o_ring - - estimate_pcf_fast + - center_Lest + - Oest + - pcf_fast - summarize_envelope - title: Null models contents: - rlabel_local - - simulate_heterogenous_pattern - - simulate_antecedent_conditions + - rheteroppp + - simulate_antecedent - title: Various contents: diff --git a/cran-comments.md b/cran-comments.md index 9d3269f..3c371b8 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,3 +1,6 @@ +# onpoint 1.1 +* Improved function names + # onpoint 1.0.6 * Minor methodological improvements diff --git a/man/estimate_o_ring.Rd b/man/Oest.Rd similarity index 87% rename from man/estimate_o_ring.Rd rename to man/Oest.Rd index a0bf7a4..8e3888d 100644 --- a/man/estimate_o_ring.Rd +++ b/man/Oest.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_o_ring.R -\name{estimate_o_ring} -\alias{estimate_o_ring} -\title{estimate_o_ring} +% Please edit documentation in R/Oest.R +\name{Oest} +\alias{Oest} +\title{Oest} \usage{ -estimate_o_ring(x, ...) +Oest(x, ...) } \arguments{ \item{x}{ppp} @@ -32,7 +32,7 @@ Returns an 'Function value object' of the \code{spatstat} package. } \examples{ input_pattern <- spatstat.random::runifpoint(n = 100) -estimate_o_ring(input_pattern) +Oest(input_pattern) } \references{ diff --git a/man/balance_points.Rd b/man/balance_points.Rd index 0350972..94b15f4 100644 --- a/man/balance_points.Rd +++ b/man/balance_points.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/balance_points.R +% Please edit documentation in R/balance-points.R \name{balance_points} \alias{balance_points} \title{balance_points} @@ -21,8 +21,8 @@ Balance number of points } \details{ The function balances out the number of points in the input pattern to either -the provided number of points as integer or the same number of points if a \code{ppp} -object is provided. +the provided number of points as integer or the same number of points if a +\code{ppp} object is provided. } \examples{ set.seed(42) diff --git a/man/calc_area.Rd b/man/calc_area.Rd index e4e17b5..ceb21ea 100644 --- a/man/calc_area.Rd +++ b/man/calc_area.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/calc_area.R +% Please edit documentation in R/calc-area.R \name{calc_area} \alias{calc_area} \title{calc_area} diff --git a/man/center_l_function.Rd b/man/center_Lest.Rd similarity index 83% rename from man/center_l_function.Rd rename to man/center_Lest.Rd index 390a324..84b0472 100644 --- a/man/center_l_function.Rd +++ b/man/center_Lest.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/center_l_function.R -\name{center_l_function} -\alias{center_l_function} -\title{center_l_function} +% Please edit documentation in R/center-Lest.R +\name{center_Lest} +\alias{center_Lest} +\title{center_Lest} \usage{ -center_l_function(x, ...) +center_Lest(x, ...) } \arguments{ \item{x}{ppp} @@ -25,10 +25,10 @@ Returns an 'Function value object' of the \code{spatstat} package. } \examples{ input_pattern <- spatstat.random::runifpoint(n = 100) -center_l_function(input_pattern, correction = "Ripley") +center_Lest(input_pattern, correction = "Ripley") lest <- spatstat.explore::Lest(input_pattern) -center_l_function(lest) +center_Lest(lest) } \references{ diff --git a/man/estimate_pcf_fast.Rd b/man/pcf_fast.Rd similarity index 84% rename from man/estimate_pcf_fast.Rd rename to man/pcf_fast.Rd index 530a63e..c5caa3a 100644 --- a/man/estimate_pcf_fast.Rd +++ b/man/pcf_fast.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/estimate_pcf_fast.R -\name{estimate_pcf_fast} -\alias{estimate_pcf_fast} -\title{estimate_pcf_fast} +% Please edit documentation in R/pcf-fast.R +\name{pcf_fast} +\alias{pcf_fast} +\title{pcf_fast} \usage{ -estimate_pcf_fast(pattern, ...) +pcf_fast(pattern, ...) } \arguments{ \item{pattern}{Point pattern.} @@ -28,7 +28,7 @@ object' of the \code{spatstat} package. \examples{ set.seed(42) pattern <- spatstat.random::runifpoint(n = 100) -pcf_fast <- estimate_pcf_fast(pattern) +pcf_fast <- pcf_fast(pattern) } \references{ diff --git a/man/plot_quantums.Rd b/man/plot_quantums.Rd index 23f5091..7ccca52 100644 --- a/man/plot_quantums.Rd +++ b/man/plot_quantums.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/plot_quantums.R +% Please edit documentation in R/plot-quantums.R \name{plot_quantums} \alias{plot_quantums} \title{plot_quantums} diff --git a/man/simulate_heterogenous_pattern.Rd b/man/rheteroppp.Rd similarity index 81% rename from man/simulate_heterogenous_pattern.Rd rename to man/rheteroppp.Rd index 0a9e816..3c4a560 100644 --- a/man/simulate_heterogenous_pattern.Rd +++ b/man/rheteroppp.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/simulate_heterogenous_pattern.R -\name{simulate_heterogenous_pattern} -\alias{simulate_heterogenous_pattern} -\title{simulate_heterogenous_pattern} +% Please edit documentation in R/rheteroppp.R +\name{rheteroppp} +\alias{rheteroppp} +\title{rheteroppp} \usage{ -simulate_heterogenous_pattern(x, nsim, fix_n = FALSE, ...) +rheteroppp(x, nsim, fix_n = FALSE, ...) } \arguments{ \item{x}{ppp} @@ -31,7 +31,7 @@ Returns a \code{list} with \code{ppp} objects. \examples{ set.seed(42) input_pattern <- spatstat.random::rpoispp(lambda = function(x , y) {100 * exp(-3 * x)}, nsim = 1) -null_model <- simulate_heterogenous_pattern(input_pattern, nsim = 19) +null_model <- rheteroppp(input_pattern, nsim = 19) spatstat.explore::envelope(Y = input_pattern, fun = spatstat.explore::pcf, nsim = 19, simulate = null_model) diff --git a/man/rlabel_local.Rd b/man/rlabel_local.Rd index d495a65..1225d15 100644 --- a/man/rlabel_local.Rd +++ b/man/rlabel_local.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/rlabel_local.R +% Please edit documentation in R/rlabel-local.R \name{rlabel_local} \alias{rlabel_local} \title{rlabel_local} diff --git a/man/simulate_antecedent_conditions.Rd b/man/simulate_antecedent.Rd similarity index 83% rename from man/simulate_antecedent_conditions.Rd rename to man/simulate_antecedent.Rd index 7cfb3e0..fce1bd5 100644 --- a/man/simulate_antecedent_conditions.Rd +++ b/man/simulate_antecedent.Rd @@ -1,10 +1,10 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/simulate_antecedent_conditions.R -\name{simulate_antecedent_conditions} -\alias{simulate_antecedent_conditions} -\title{simulate_antecedent_conditions} +% Please edit documentation in R/simulate-antecedent.R +\name{simulate_antecedent} +\alias{simulate_antecedent} +\title{simulate_antecedent} \usage{ -simulate_antecedent_conditions(x, i, j, nsim, heterogenous = FALSE, ...) +simulate_antecedent(x, i, j, nsim, heterogenous = FALSE, ...) } \arguments{ \item{x}{ppp} @@ -44,7 +44,7 @@ pattern_b <- spatstat.random::runifpoint(n = 100) spatstat.geom::marks(pattern_b) <- "b" pattern <- spatstat.geom::superimpose(pattern_a, pattern_b) -null_model <- simulate_antecedent_conditions(x = pattern, i = "a", j = "b", nsim = 19) +null_model <- simulate_antecedent(x = pattern, i = "a", j = "b", nsim = 19) spatstat.explore::envelope(Y = pattern, fun = spatstat.explore::pcf, nsim = 19, simulate = null_model) diff --git a/man/split_at.Rd b/man/split_at.Rd index 2c98f31..8489bdb 100644 --- a/man/split_at.Rd +++ b/man/split_at.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/split_at.R +% Please edit documentation in R/split-at.R \name{split_at} \alias{split_at} \title{split_at} diff --git a/man/summarize_envelope.Rd b/man/summarize_envelope.Rd index 95cb1be..d87ee7a 100644 --- a/man/summarize_envelope.Rd +++ b/man/summarize_envelope.Rd @@ -1,5 +1,5 @@ % Generated by roxygen2: do not edit by hand -% Please edit documentation in R/summarize_envelope.R +% Please edit documentation in R/summarize-envelope.R \name{summarize_envelope} \alias{summarize_envelope} \title{summarize_envelope} diff --git a/onpoint.Rproj b/onpoint.Rproj index 3509a42..52dae2f 100644 --- a/onpoint.Rproj +++ b/onpoint.Rproj @@ -1,4 +1,5 @@ Version: 1.0 +ProjectId: e3e89b31-8d79-4b77-91e1-2ee46ff563e6 RestoreWorkspace: Default SaveWorkspace: Default diff --git a/tests/testthat/test-Oest.R b/tests/testthat/test-Oest.R new file mode 100644 index 0000000..08a1a82 --- /dev/null +++ b/tests/testthat/test-Oest.R @@ -0,0 +1,17 @@ +# context("test-Oest") + +test_that("Oest returns fv", { + + input_pattern <- spatstat.random::runifpoint(n = 100) + + result <- Oest(x = input_pattern) + + expect_true(spatstat.geom::is.fv(x = result)) + +}) + +test_that("Oest returns error", { + + expect_error(Oest(x = c(1, 2, 3)), regexp = "Please provide ppp.") + +}) diff --git a/tests/testthat/test-center_Lest.R b/tests/testthat/test-center_Lest.R new file mode 100644 index 0000000..05c29c2 --- /dev/null +++ b/tests/testthat/test-center_Lest.R @@ -0,0 +1,27 @@ +# context("test-center_Lest") + +test_that("center_Lest works for point pattern", { + + input_pattern <- spatstat.random::runifpoint(n = 100) + + result <- center_Lest(input_pattern, correction = "Ripley") + + expect_true(spatstat.geom::is.fv(result)) +}) + +test_that("center_Lest works for fv object", { + + input_pattern <- spatstat.random::runifpoint(n = 100) + + lest <- spatstat.explore::Lest(input_pattern) + + result <- center_Lest(lest, correction = "Ripley") + + expect_true(spatstat.geom::is.fv(result)) +}) + +test_that("center_Lest returns error", { + + expect_error(center_Lest(x = c(1, 2, 3)), + regexp = "Please provide either ppp or fv object.") +}) diff --git a/tests/testthat/test-center_l_function.R b/tests/testthat/test-center_l_function.R deleted file mode 100644 index 02b6027..0000000 --- a/tests/testthat/test-center_l_function.R +++ /dev/null @@ -1,28 +0,0 @@ -# context("test-center_l_function") - -test_that("center_l_function works for point pattern", { - - input_pattern <- spatstat.random::runifpoint(n = 100) - - result <- center_l_function(input_pattern, correction = "Ripley") - - expect_true(spatstat.geom::is.fv(result)) -}) - -test_that("center_l_function works for fv object", { - - input_pattern <- spatstat.random::runifpoint(n = 100) - - lest <- spatstat.explore::Lest(input_pattern) - - result <- center_l_function(lest, correction = "Ripley") - - expect_true(spatstat.geom::is.fv(result)) -}) - -test_that("center_l_function returns error", { - - expect_error(center_l_function(x = c(1, 2, 3)), - regexp = "Please provide either ppp or fv object.") -}) - diff --git a/tests/testthat/test-estimate_o_ring.R b/tests/testthat/test-estimate_o_ring.R deleted file mode 100644 index 7a0a71f..0000000 --- a/tests/testthat/test-estimate_o_ring.R +++ /dev/null @@ -1,16 +0,0 @@ -# context("test-estimate_o_ring") - -test_that("estimate_o_ring returns fv", { - - input_pattern <- spatstat.random::runifpoint(n = 100) - - result <- estimate_o_ring(x = input_pattern) - - expect_true(spatstat.geom::is.fv(x = result)) -}) - -test_that("estimate_o_ring returns error", { - - expect_error(estimate_o_ring(x = c(1, 2, 3)), - regexp = "Please provide ppp.") -}) diff --git a/tests/testthat/test-estimate_pcf_fast.R b/tests/testthat/test-pcf_fast.R similarity index 65% rename from tests/testthat/test-estimate_pcf_fast.R rename to tests/testthat/test-pcf_fast.R index c7474bd..983935b 100644 --- a/tests/testthat/test-estimate_pcf_fast.R +++ b/tests/testthat/test-pcf_fast.R @@ -1,10 +1,11 @@ -# testthat::context("test-estimate_pcf_fast") +# testthat::context("test-pcf_fast") testthat::test_that("estimate_pcf returns spatstat.fv object", { pattern <- spatstat.random::runifpoint(n = 100) - pcf_est <- estimate_pcf_fast(pattern) + pcf_est <- pcf_fast(pattern) testthat::expect_s3_class(pcf_est, "fv") }) + diff --git a/tests/testthat/test-simulate_heterogenous_pattern.R b/tests/testthat/test-rheteroppp.R similarity index 59% rename from tests/testthat/test-simulate_heterogenous_pattern.R rename to tests/testthat/test-rheteroppp.R index 6904c5f..2a9c00c 100644 --- a/tests/testthat/test-simulate_heterogenous_pattern.R +++ b/tests/testthat/test-rheteroppp.R @@ -1,10 +1,10 @@ -# context("test-simulate_heterogenous_pattern") +# context("test-rheteroppp") -test_that("simulate_heterogenous_pattern returns ppp", { +test_that("rheteroppp returns ppp", { input_pattern <- spatstat.random::rpoispp(lambda = function(x , y) {100 * exp(-3 * x)}, nsim = 1) - result <- simulate_heterogenous_pattern(input_pattern, nsim = 9) + result <- rheteroppp(input_pattern, nsim = 9) n <- vapply(result, function(x) x$n, FUN.VALUE = numeric(1)) @@ -13,11 +13,11 @@ test_that("simulate_heterogenous_pattern returns ppp", { expect_true(!all(n == input_pattern$n)) }) -test_that("fix_n is working for simulate_heterogenous_pattern", { +test_that("fix_n is working for rheteroppp", { input_pattern <- spatstat.random::rpoispp(lambda = function(x , y) {100 * exp(-3 * x)}, nsim = 1) - result <- simulate_heterogenous_pattern(input_pattern, nsim = 9, fix_n = TRUE) + result <- rheteroppp(input_pattern, nsim = 9, fix_n = TRUE) n <- vapply(result, function(x) x$n, FUN.VALUE = numeric(1)) @@ -26,9 +26,9 @@ test_that("fix_n is working for simulate_heterogenous_pattern", { expect_true(all(n == input_pattern$n)) }) -test_that("simulate_heterogenous_pattern returns error", { +test_that("rheteroppp returns error", { - expect_error(simulate_heterogenous_pattern(c(1, 2, 3 ), nsim = 9), + expect_error(rheteroppp(c(1, 2, 3 ), nsim = 9), regexp = "Please provide ppp object.") }) diff --git a/tests/testthat/test-simulate_antecedent_conditions.R b/tests/testthat/test-simulate_antecedent.R similarity index 57% rename from tests/testthat/test-simulate_antecedent_conditions.R rename to tests/testthat/test-simulate_antecedent.R index ba1b705..9259cf7 100644 --- a/tests/testthat/test-simulate_antecedent_conditions.R +++ b/tests/testthat/test-simulate_antecedent.R @@ -1,4 +1,4 @@ -# context("test-simulate_antecedent_conditions") +# context("test-simulate_antecedent") pattern_a <- spatstat.random::runifpoint(n = 20) spatstat.geom::marks(pattern_a) <- "a" @@ -8,19 +8,16 @@ spatstat.geom::marks(pattern_b) <- "b" pattern <- spatstat.geom::superimpose(pattern_a, pattern_b) -test_that("simulate_antecedent_conditions returns nsim", { +test_that("simulate_antecedent returns nsim", { - null_model <- simulate_antecedent_conditions(x = pattern, - i = "b", j = "a", - nsim = 19) + null_model <- simulate_antecedent(x = pattern, i = "b", j = "a", nsim = 19) expect_length(null_model, n = 19) }) -test_that("simulate_antecedent_conditions does not randomize pattern i", { +test_that("simulate_antecedent does not randomize pattern i", { - null_model <- simulate_antecedent_conditions(x = pattern, i = "b", j = "a", - nsim = 19) + null_model <- simulate_antecedent(x = pattern, i = "b", j = "a", nsim = 19) pattern_i <- spatstat.geom::subset.ppp(null_model[[1]], marks == "b") @@ -30,9 +27,9 @@ test_that("simulate_antecedent_conditions does not randomize pattern i", { expect_true(check) }) -test_that("simulate_antecedent_conditions randomizes pattern j", { +test_that("simulate_antecedent randomizes pattern j", { - null_model <- simulate_antecedent_conditions(x = pattern, + null_model <- simulate_antecedent(x = pattern, i = "b", j = "a", nsim = 19) @@ -44,9 +41,9 @@ test_that("simulate_antecedent_conditions randomizes pattern j", { expect_true(check) }) -test_that("simulate_antecedent_conditions uses heterogenous process", { +test_that("simulate_antecedent uses heterogenous process", { - null_model <- simulate_antecedent_conditions(x = pattern, + null_model <- simulate_antecedent(x = pattern, i = "b", j = "a", nsim = 19, heterogenous = TRUE) @@ -54,18 +51,18 @@ test_that("simulate_antecedent_conditions uses heterogenous process", { expect_length(null_model, n = 19) }) -test_that("simulate_antecedent_conditions returns error", { +test_that("simulate_antecedent returns error", { pattern_unmarked <- spatstat.random::runifpoint(n = 100) - expect_error(simulate_antecedent_conditions(x = pattern_unmarked), + expect_error(simulate_antecedent(x = pattern_unmarked), regexp = "Please provide marked point pattern.") - expect_error(simulate_antecedent_conditions(x = pattern, i = "a", j = "c"), + expect_error(simulate_antecedent(x = pattern, i = "a", j = "c"), regexp = "i and j must be marks of x.") spatstat.geom::marks(pattern[1]) <- "c" - expect_error(simulate_antecedent_conditions(x = pattern, i = "a", j = "b"), + expect_error(simulate_antecedent(x = pattern, i = "a", j = "b"), regexp = "Currently only bivariate point patterns are supported.") })