From 7b846f1363bc168758996e6945514375437a9d0c Mon Sep 17 00:00:00 2001 From: rCarto Date: Tue, 19 Jan 2021 12:05:20 +0100 Subject: [PATCH] CRAN Submission --- DESCRIPTION | 2 +- NEWS.md | 8 ++++++++ R/getgrid.R | 7 +++++-- R/package.R | 12 ++++++++---- inst/tinytest/test_linemap.R | 3 ++- man/getgrid.Rd | 3 ++- man/linemap-package.Rd | 12 ++++++++---- 7 files changed, 34 insertions(+), 13 deletions(-) create mode 100644 NEWS.md diff --git a/DESCRIPTION b/DESCRIPTION index 6e9f5af..1c5a324 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: linemap Type: Package Title: Line Maps -Version: 0.1.1 +Version: 0.2.0 Authors@R: person("Timothée", "Giraud", email = "timothee.giraud@cnrs.fr", role = c("cre","aut"), comment = c(ORCID = "0000-0002-1932-3323")) Description: Create maps made of lines. The package contains two functions: diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000..3b6d462 --- /dev/null +++ b/NEWS.md @@ -0,0 +1,8 @@ +# linemap 0.2.0 + +## Minor changes +- Remove some RData in favor of geopackage (This can lead to breaking changes using examples) +- fix NOTES by importing geopackage instead of RData +- Add test, code coverage and GH action +- Fix links + diff --git a/R/getgrid.R b/R/getgrid.R index 17578ff..c79f008 100644 --- a/R/getgrid.R +++ b/R/getgrid.R @@ -3,7 +3,8 @@ #' @description Transform a polygon layer to a regular grid data.frame. #' @param x an sf polygon layer. #' @param cellsize size of the side of a grid cell. -#' @param var name of the variable to transform to the grid. It can be a vector of names. +#' @param var name of the variable to transform to the grid. It can be a vector +#' of names. #' @return A data frame is returned. #' @export #' @examples @@ -66,7 +67,9 @@ getgrid <- function(x, cellsize, var){ lvar <- vector(mode = "list", length = length(var)) names(lvar) <- var for (i in 1:length(lvar)){ - lvar[[i]] <- as.vector(parts[[names(lvar)[i]]] * parts$area_part / parts$area) + lvar[[i]] <- as.vector( + parts[[names(lvar)[i]]] * parts$area_part / parts$area + ) } v <- stats::aggregate(do.call(cbind,lvar), by = list(id = parts[['id_cell']]), FUN = sum, na.rm=TRUE) diff --git a/R/package.R b/R/package.R index 35a6d01..5233274 100644 --- a/R/package.R +++ b/R/package.R @@ -2,14 +2,18 @@ #' @rdname linemap-package #' @name linemap-package #' @description -#' Create maps made of lines. The package contains two functions: \code{\link{linemap}} and \code{\link{getgrid}}. +#' Create maps made of lines. The package contains two functions: +#' \code{\link{linemap}} and \code{\link{getgrid}}. #' -#' \code{\link{linemap}} displays a map made of lines using a data frame of gridded data. +#' \code{\link{linemap}} displays a map made of lines using a data frame of +#' gridded data. #' -#' \code{\link{getgrid}} transforms a set of polygons (\code{\link{sf}} objects) into a suitable data frame +#' \code{\link{getgrid}} transforms a set of polygons (\code{\link{sf}} objects) +#' into a suitable data frame #' for \code{\link{linemap}}. #' @note -#' These three mains sources gave me the inspiration to create \code{linemap}:\cr +#' These three mains sources gave me the inspiration to create +#' \code{linemap}:\cr #' - Joy Division's 'Unknown Pleasures' Cover (\url{https://en.wikipedia.org/wiki/Unknown_Pleasures}) \cr #' - the work of James Cheshire (Population Lines: How and Why I Created It - \url{https://jcheshire.com/featured-maps/population-lines-how-and-why-i-created-it/})\cr #' - the work of Ryan Brideau (GeospatialLineGraphs - \url{https://github.com/Brideau/GeospatialLineGraphs})\cr diff --git a/inst/tinytest/test_linemap.R b/inst/tinytest/test_linemap.R index 26022d7..75d43ee 100644 --- a/inst/tinytest/test_linemap.R +++ b/inst/tinytest/test_linemap.R @@ -2,7 +2,8 @@ data("popOcc") popToulouse <- popOcc[findInterval(popOcc$X, c(3600234,3659444)) == 1 & findInterval(popOcc$Y, c(2290913,2348192)) == 1, ] expect_silent(linemap(x = popToulouse, var = "pop", k = 2.5, threshold = 50, - col = "ivory1", border = "ivory4", lwd = 0.6, add = FALSE)) + col = "ivory1", border = "ivory4", lwd = 0.6, + add = FALSE)) expect_silent(linemap(x = popToulouse, var = "pop", add = TRUE)) diff --git a/man/getgrid.Rd b/man/getgrid.Rd index 5b21149..37bf6f4 100644 --- a/man/getgrid.Rd +++ b/man/getgrid.Rd @@ -11,7 +11,8 @@ getgrid(x, cellsize, var) \item{cellsize}{size of the side of a grid cell.} -\item{var}{name of the variable to transform to the grid. It can be a vector of names.} +\item{var}{name of the variable to transform to the grid. It can be a vector +of names.} } \value{ A data frame is returned. diff --git a/man/linemap-package.Rd b/man/linemap-package.Rd index 00c7833..5ca83a4 100644 --- a/man/linemap-package.Rd +++ b/man/linemap-package.Rd @@ -5,15 +5,19 @@ \alias{linemap-package} \title{Line Map Package} \description{ -Create maps made of lines. The package contains two functions: \code{\link{linemap}} and \code{\link{getgrid}}. +Create maps made of lines. The package contains two functions: +\code{\link{linemap}} and \code{\link{getgrid}}. -\code{\link{linemap}} displays a map made of lines using a data frame of gridded data. +\code{\link{linemap}} displays a map made of lines using a data frame of +gridded data. -\code{\link{getgrid}} transforms a set of polygons (\code{\link{sf}} objects) into a suitable data frame +\code{\link{getgrid}} transforms a set of polygons (\code{\link{sf}} objects) +into a suitable data frame for \code{\link{linemap}}. } \note{ -These three mains sources gave me the inspiration to create \code{linemap}:\cr +These three mains sources gave me the inspiration to create +\code{linemap}:\cr - Joy Division's 'Unknown Pleasures' Cover (\url{https://en.wikipedia.org/wiki/Unknown_Pleasures}) \cr - the work of James Cheshire (Population Lines: How and Why I Created It - \url{https://jcheshire.com/featured-maps/population-lines-how-and-why-i-created-it/})\cr - the work of Ryan Brideau (GeospatialLineGraphs - \url{https://github.com/Brideau/GeospatialLineGraphs})\cr