Skip to content

Commit

Permalink
ready for CRAN submission
Browse files Browse the repository at this point in the history
  • Loading branch information
mtennekes committed Jan 13, 2025
1 parent 4d2385f commit caf1b29
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 26 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ appveyor.yml
^docs$
^pkgdown$
^\.github$
^CRAN-SUBMISSION$
3 changes: 1 addition & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ Authors@R: person("Martijn", "Tennekes", email = "[email protected]", role = c
Description: Set of tools for reading and processing spatial data. The aim is to supply the workflow to create thematic maps. This package also facilitates 'tmap', the package for visualizing thematic maps.
License: GPL-3
Encoding: UTF-8
LazyData: true
Date: 2025-01-03
Date: 2025-01-13
Depends:
R (>= 3.5),
methods
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# version 3.2
- examples updated with tmap4
- deprecated some functions

# version 3.1-1
- fixed minor bugs (see github)

Expand Down
2 changes: 1 addition & 1 deletion R/calc_densities.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#'
#' Transpose quantitative variables to densitiy variables, which are often needed for choroplets. For example, the colors of a population density map should correspond population density counts rather than absolute population numbers.
#'
#' @param shp a shape object, i.e., an \code{\link[sf:sf]{sf}} object or a \code{SpatialPolygons(DataFrame)} from the \code{sp} package.
#' @param shp a shape object, i.e., an \code{\link[sf:sf]{sf}} object.
#' @param var name(s) of a qualtity variable name contained in the \code{shp} data
#' @param target the target unit, see \code{\link{approx_areas}}. Density values are calculated in \code{var/target^2}.
#' @param total.area total area size of \code{shp} in number of target units (defined by \code{unit}), \code{\link{approx_areas}}.
Expand Down
7 changes: 5 additions & 2 deletions R/get_brewer_pal.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Get and plot a (modified) Color Brewer palette
#' Get and plot a (modified) Color Brewer palette (deprecated)
#'
#' Get and plot a (modified) palette from Color Brewer. In addition to the base function \code{\link[RColorBrewer:ColorBrewer]{brewer.pal}}, a palette can be created for any number of classes. The contrast of the palette can be adjusted for sequential and diverging palettes. For categorical palettes, intermediate colors can be generated. An interactive tool that uses this function is \code{\link{palette_explorer}}.
#' Get and plot a (modified) palette from Color Brewer. This function is deprecated. Please use \code{\link[cols4all:c4a]{c4a}} instead.
#'
#' The default contrast of the palette depends on the number of colors, \code{n}, in the following way. The default contrast is maximal, so \code{(0, 1)}, when \code{n = 9} for sequential palettes and \code{n = 11} for diverging palettes. The default contrast values for smaller values of \code{n} can be extracted with some R magic: \code{sapply(1:9, tmaptools:::default_contrast_seq)} for sequential palettes and \code{sapply(1:11, tmaptools:::default_contrast_div)} for diverging palettes.
#'
Expand All @@ -16,6 +16,9 @@
#' @importFrom RColorBrewer brewer.pal brewer.pal.info
#' @export
get_brewer_pal <- function(palette, n=5, contrast=NA, stretch=TRUE, plot=TRUE) {

message("This function is deprecated; please use cols4all::c4a() instead")

call <- names(match.call(expand.dots = TRUE)[-1])

reverse <- (substr(palette, 1, 1) == "-")
Expand Down
22 changes: 13 additions & 9 deletions examples/calc_densities.R
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
if (require(tmap) && packageVersion("tmap") >= "3.99") {
data(NLD_muni)
data(NLD_muni)

NLD_muni_pop_per_km2 <- calc_densities(NLD_muni,
target = "km km", var = c("population", "dwelling_total"))
NLD_muni <- sf::st_sf(data.frame(NLD_muni, NLD_muni_pop_per_km2))
NLD_muni_pop_per_km2 <- calc_densities(NLD_muni,
target = "km km", var = c("population", "dwelling_total"))
NLD_muni <- sf::st_sf(data.frame(NLD_muni, NLD_muni_pop_per_km2))

tm_shape(NLD_muni) +
tm_polygons(c("population_km.2", "dwelling_total_km.2"),
fill.legend = list(tm_legend(expression("Population per " * km^2)), tm_legend(expression("Dwellings per " * km^2)))) +
tm_facets(free.scales = TRUE) +
tm_layout(panel.show = FALSE)
tm_shape(NLD_muni) +
tm_polygons(
fill = c("population_km.2", "dwelling_total_km.2"),
fill.legend =
list(
tm_legend(expression("Population per " * km^2)),
tm_legend(expression("Dwellings per " * km^2)))) +
tm_facets(free.scales = TRUE) +
tm_layout(panel.show = FALSE)
}
24 changes: 14 additions & 10 deletions man/calc_densities.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions man/get_brewer_pal.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit caf1b29

Please sign in to comment.