diff --git a/DESCRIPTION b/DESCRIPTION index 8dfa05f..ed1116c 100755 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -24,7 +24,7 @@ License: GPL (>= 2) Imports: survey, stats, spdep, survival, ggplot2, scales, utils, Matrix, reshape2, viridis, sp, sf, shadowtext, ggridges, methods, data.table, RColorBrewer, grDevices, fields, terra, haven Encoding: UTF-8 LazyData: true -RoxygenNote: 7.3.1 +RoxygenNote: 7.3.2 Additional_repositories: https://inla.r-inla-download.org/R/testing/ Suggests: INLA, knitr, rmarkdown, readstata13, patchwork, rdhs, R.rsp, sae, dplyr, tidyr, raster VignetteBuilder: R.rsp, knitr diff --git a/NAMESPACE b/NAMESPACE index 4e1c377..34283da 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -106,6 +106,7 @@ importFrom(stats,na.pass) importFrom(stats,qnorm) importFrom(stats,quantile) importFrom(stats,rbinom) +importFrom(stats,rnorm) importFrom(stats,runif) importFrom(stats,sd) importFrom(stats,setNames) diff --git a/R/getSmoothedDensity.R b/R/getSmoothedDensity.R index 6e7c675..5e27f39 100644 --- a/R/getSmoothedDensity.R +++ b/R/getSmoothedDensity.R @@ -21,6 +21,7 @@ #' @return ridge plot of the density, and if \code{save.density = TRUE}, also a data frame of the calculated densities #' @seealso \code{\link{plot.SUMMERproj}} #' @importFrom methods as +#' @importFrom stats rnorm #' @author Zehang Richard Li #' @examples #' \dontrun{ @@ -70,6 +71,26 @@ #' ncol = 4, by.year=FALSE, per1000 = TRUE) #' #' +#' # Example using surveyPrev package output +#' +#' library(surveyPrev) +#' dhsData <- getDHSdata(country = "Rwanda", indicator = "nmr", year = 2019) +#' data <- getDHSindicator(dhsData, indicator = "nmr") +#' geo <- getDHSgeo(country = "Rwanda", year = 2019) +#' poly.adm1 <- geodata::gadm(country="RWA", level=1, path=tempdir()) +#' poly.adm1 <- sf::st_as_sf(poly.adm1) +#' poly.adm2 <- geodata::gadm(country="RWA", level=2, path=tempdir()) +#' poly.adm2 <- sf::st_as_sf(poly.adm2) +#' cluster.info <- clusterInfo(geo = geo, +#' poly.adm1 = poly.adm1, +#' poly.adm2 = poly.adm2, +#' by.adm1 = "NAME_1", +#' by.adm2 = "NAME_2") +#' +#' fit1 <- directEST(data = data, cluster.info = cluster.info, admin = 1) +#' fit2 <- directEST(data = data, cluster.info = cluster.info, admin = 2) +#' ridgePlot(fit1, direction = -1) +#' ridgePlot(fit2, direction = -1) #' #' } #' diff --git a/man/ridgePlot.Rd b/man/ridgePlot.Rd index 2e0f014..c15a0e8 100644 --- a/man/ridgePlot.Rd +++ b/man/ridgePlot.Rd @@ -126,6 +126,26 @@ ridgePlot(results = density, year_plot = c(1990:2019), ncol = 4, by.year=FALSE, per1000 = TRUE) +# Example using surveyPrev package output + +library(surveyPrev) +dhsData <- getDHSdata(country = "Rwanda", indicator = "nmr", year = 2019) +data <- getDHSindicator(dhsData, indicator = "nmr") +geo <- getDHSgeo(country = "Rwanda", year = 2019) +poly.adm1 <- geodata::gadm(country="RWA", level=1, path=tempdir()) +poly.adm1 <- sf::st_as_sf(poly.adm1) +poly.adm2 <- geodata::gadm(country="RWA", level=2, path=tempdir()) +poly.adm2 <- sf::st_as_sf(poly.adm2) +cluster.info <- clusterInfo(geo = geo, + poly.adm1 = poly.adm1, + poly.adm2 = poly.adm2, + by.adm1 = "NAME_1", + by.adm2 = "NAME_2") + +fit1 <- directEST(data = data, cluster.info = cluster.info, admin = 1) +fit2 <- directEST(data = data, cluster.info = cluster.info, admin = 2) +ridgePlot(fit1, direction = -1) +ridgePlot(fit2, direction = -1) }