Skip to content

Commit

Permalink
Merge pull request #26 from USEPA/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
michaeldumelle authored Dec 15, 2021
2 parents 9d03e4e + cd0865f commit 8cceaec
Show file tree
Hide file tree
Showing 64 changed files with 1,939 additions and 399 deletions.
2 changes: 1 addition & 1 deletion .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
^Meta$
^\.github$
^LICENSE\.md$
^NEWS.md$
^notes.md$
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ spsurvey.Rproj
inst/doc
/doc/
/Meta/
notes.md
5 changes: 3 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: spsurvey
Title: Spatial Sampling Design and Analysis
Version: 5.0.1
Version: 5.1.0
Authors@R: c(
person("Michael", "Dumelle", role=c("aut","cre"),
email = "[email protected]", comment = c(ORCID = "0000-0002-3393-5529")),
Expand All @@ -27,6 +27,7 @@ Imports:
grDevices,
lme4,
MASS,
sampling,
stats,
units
Suggests:
Expand All @@ -39,5 +40,5 @@ BugReports: https://github.com/USEPA/spsurvey/issues
VignetteBuilder: knitr
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.1
RoxygenNote: 7.1.2
NeedsCompilation: no
4 changes: 4 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ export(diffrisk_analysis)
export(errorprnt)
export(grts)
export(irs)
export(localmean_cov)
export(localmean_var)
export(localmean_weight)
export(pd_summary)
export(power_dsgn)
export(ppd_plot)
Expand Down Expand Up @@ -54,6 +57,7 @@ importFrom(graphics,text)
importFrom(graphics,title)
importFrom(lme4,VarCorr)
importFrom(lme4,lmer)
importFrom(sampling,UPpivotal)
importFrom(stats,addmargins)
importFrom(stats,chisq.test)
importFrom(stats,confint)
Expand Down
23 changes: 21 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
# spsurvey 5.1.0 (2021-12-14)

## Minor updates

* Added a `Total` option to the `statistics` argument in `cont_analysis()`.
* Added `localmean_weight()`, `localmean_var()`, and `localmean_cov()` functions to compute the local neighborhood variance estimator outside of the `*_analysis()` functions.
* Added an option to provide a bounding box vector to the `fix_bbox` argument in `sp_plot()`.
* Added an error message to `grts() ` and `irs()` that stops the function when geographic coordinates are used.
* Added an error message to `grts()` and `irs()` that stops the function when too many expected samples are specified for at least one level of an unequal probability variable.
* Added a `caty_n_over` argument to `grts()` and `irs()` that makes it easier to specify reverse hierarchically ordered replacement sites for unequal probability sampling designs.
* Added vector argument support for the `n_over` and `n_near` arguments in `grts()` and `irs()` (list arguments were already supported).
* Added a default value for `siteID` in `attrisk_analysis()`, `cat_analysis()`, `cont_analysis()`, `diffrisk_analysis()`, and `relrisk_analysis()` that assumes each row in `dframe` represents a unique site.

## Bug fixes

* Fixed a bug in `irs()` that made the algorithm sensitive to the ordering of `sframe`.
* Fixed a bug in percentile estimation from `cont_analysis()` that incorrectly copied estimate values.
* Fixed a bug in `grts()` and `irs()` that prevented sampling from `sframe` when the geometry type was `LINESTRING`, `MULTILINESTRING`, `POLYGON`, or `MULTIPOLYGON` and the number of desired samples exceeded the number of rows.

# spsurvey 5.0.1 (2021-10-18)

## Bug fix
Expand Down Expand Up @@ -50,7 +69,7 @@ this is reported on the CRAN results pages for fedora-clang and fedora-gcc.

## Bug fix

* Update test data and Description file to handle changes in `sf` and changes to `crs` described [here](https://www.r-spatial.org/r/2020/03/17/wkt.html)
* Update test data and Description file to handle changes in `sf` and changes to `crs` described [here](https://r-spatial.org/r/2020/03/17/wkt.html)

# spsurvey 4.1.1 (2019-12-12)

Expand All @@ -66,7 +85,7 @@ this is reported on the CRAN results pages for fedora-clang and fedora-gcc.
* The package no longer contains any functions written in C. The C functions were either no longer required due to the transition to use of `sf` objects to contain the survey frame or were replaced with functions written in R. The new R functions are: `cellWeight`, `constructAddr`, `insideAreaGridCell`, `insideLinearGridCell`, `make_grid`, `numLevels`, `pickFiniteSamplePoints`, `pickGridCells`, `pickSamplePoints`, `ranho`, and `selectFeatureID`.

## Bug fixes
* The new R code function named `numLevels` that determines the number of hierarchical levels for a generalized random-tesselation stratified (GRTS) survey design now includes code to ensure that the maximum number of levels (which is currently 11) is not bypassed when creating a survey design.
* The new R code function named `numLevels` that determines the number of hierarchical levels for a generalized random-tessellation stratified (GRTS) survey design now includes code to ensure that the maximum number of levels (which is currently 11) is not bypassed when creating a survey design.

## Modified function
* Modified function `input.check` to check for missing values among the x-coordinates and y-coordinates for location.
Expand Down
94 changes: 0 additions & 94 deletions R/UPpivotal.R

This file was deleted.

14 changes: 11 additions & 3 deletions R/attrisk_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
#'
#' @param response_levels List providing the category values (levels) for each
#' element in the \code{vars_response} argument. Each element in the list
#' must contian two values, where the first value identifies poor condition,
#' must contain two values, where the first value identifies poor condition,
#' and the second value identifies good condition. This argument must be
#' named and must be the same length as argument \code{vars_response}. Names
#' for this argument must match the values in the \code{vars_response}
Expand Down Expand Up @@ -85,7 +85,8 @@
#'
#' @param siteID Character value providing the name of the site ID variable in
#' \code{dframe}. For a two-stage sample, the site ID variable
#' identifies stage two site IDs. The default value is \code{"siteID"}.
#' identifies stage two site IDs. The default value is \code{NULL}, which
#' assumes that each row in \code{dframe} represents a unique site.
#'
#' @param weight Character value providing the name of the design weight
#' variable in \code{dframe}. For a two-stage sample, the
Expand Down Expand Up @@ -340,7 +341,7 @@
################################################################################

attrisk_analysis <- function(dframe, vars_response, vars_stressor, response_levels = NULL,
stressor_levels = NULL, subpops = NULL, siteID = "siteID", weight = "weight",
stressor_levels = NULL, subpops = NULL, siteID = NULL, weight = "weight",
xcoord = NULL, ycoord = NULL, stratumID = NULL, clusterID = NULL,
weight1 = NULL, xcoord1 = NULL, ycoord1 = NULL, sizeweight = FALSE,
sweight = NULL, sweight1 = NULL, fpc = NULL, popsize = NULL,
Expand Down Expand Up @@ -394,6 +395,13 @@ attrisk_analysis <- function(dframe, vars_response, vars_stressor, response_leve

dframe <- droplevels(dframe)

# If no siteID is provided, set one that assumes each row is a unique site

if (is.null(siteID)) {
siteID <- "siteID"
dframe$siteID <- paste("site", seq_len(nrow(dframe)), sep = "-")
}

# Ensure that the dframe data frame contains the site ID variable

if (!(siteID %in% names(dframe))) {
Expand Down
12 changes: 10 additions & 2 deletions R/cat_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
#'
#' @param siteID Character value providing name of the site ID variable in
#' the \code{dframe} data frame. For a two-stage sample, the site ID variable
#' identifies stage two site IDs. The default value is \code{"siteID"}.
#' identifies stage two site IDs. The default value is \code{NULL}, which
#' assumes that each row in \code{dframe} represents a unique site.
#'
#' @param weight Character value providing name of the design weight
#' variable in \code{dframe}. For a two-stage sample, the
Expand Down Expand Up @@ -284,7 +285,7 @@
#' @export
################################################################################

cat_analysis <- function(dframe, vars, subpops = NULL, siteID = "siteID", weight = "weight",
cat_analysis <- function(dframe, vars, subpops = NULL, siteID = NULL, weight = "weight",
xcoord = NULL, ycoord = NULL, stratumID = NULL, clusterID = NULL,
weight1 = NULL, xcoord1 = NULL, ycoord1 = NULL, sizeweight = FALSE,
sweight = NULL, sweight1 = NULL, fpc = NULL, popsize = NULL,
Expand Down Expand Up @@ -338,6 +339,13 @@ cat_analysis <- function(dframe, vars, subpops = NULL, siteID = "siteID", weight

dframe <- droplevels(dframe)

# If no siteID is provided, set one that assumes each row is a unique site

if (is.null(siteID)) {
siteID <- "siteID"
dframe$siteID <- paste("site", seq_len(nrow(dframe)), sep = "-")
}

# Ensure that the dframe data frame contains the site ID variable

if (!(siteID %in% names(dframe))) {
Expand Down
2 changes: 2 additions & 0 deletions R/cdf_plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
#' @keywords survey
#'
#' @examples
#' \dontrun{
#' dframe <- data.frame(
#' siteID = paste0("Site", 1:100),
#' wgt = runif(100, 10, 100),
Expand Down Expand Up @@ -135,6 +136,7 @@
#' ylab = "Percent of Stream Length", ylab_r = "Same",
#' main = "Estimates for Resource Class: Good"
#' )
#' }
#' @export
################################################################################

Expand Down
2 changes: 1 addition & 1 deletion R/change_analysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
#' named vector containing one more than the number of clusters in the sample,
#' where the first item in the vector specifies the number of clusters in the
#' population and each subsequent item specifies the number of stage two units
#' for the cluster. The name for the first item in the vector is arbitrry.
#' for the cluster. The name for the first item in the vector is arbitrary.
#' Subsequent names in the vector identify clusters and must match the cluster
#' IDs. For a stratified design, the object is a named list of vectors, where
#' names must match the strata IDs. For each stratum, the format of the
Expand Down
Loading

0 comments on commit 8cceaec

Please sign in to comment.