diff --git a/.buildlibrary b/.buildlibrary index 47e9015..1a33dbe 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '7948400' +ValidationKey: '7971479' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/CITATION.cff b/CITATION.cff index 5d24437..44bce53 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'luplot: Landuse Plot Library' -version: 4.0.0 -date-released: '2024-05-28' +version: 4.0.1 +date-released: '2024-06-05' abstract: Some useful functions to plot data such as a map plot function for MAgPIE objects. authors: diff --git a/DESCRIPTION b/DESCRIPTION index 8b12144..fee0c06 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: luplot Title: Landuse Plot Library -Version: 4.0.0 -Date: 2024-05-28 +Version: 4.0.1 +Date: 2024-06-05 Authors@R: c( person("Benjamin Leon", "Bodirsky", , "bodirsky@pik-potsdam.de", role = c("aut", "cre")), person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"), @@ -37,10 +37,10 @@ Imports: quitte, RColorBrewer, reshape2, - rworldmap (>= 1.3.8), utils Suggests: - covr + covr, + rworldmap (>= 1.3.8) Encoding: UTF-8 LazyData: no RoxygenNote: 7.3.1 diff --git a/NAMESPACE b/NAMESPACE index 5d92f63..770526f 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -107,8 +107,6 @@ importFrom(mip,plotstyle) importFrom(mstools,toolGetMappingCoord2Country) importFrom(quitte,as.quitte) importFrom(reshape2,melt) -importFrom(rworldmap,joinCountryData2Map) -importFrom(rworldmap,mapCountryData) importFrom(stats,as.formula) importFrom(stats,cor) importFrom(stats,cor.test) diff --git a/R/plotcountrymap.R b/R/plotcountrymap.R index e4291c7..4c920cf 100644 --- a/R/plotcountrymap.R +++ b/R/plotcountrymap.R @@ -23,11 +23,13 @@ #' } #' @export #'@importFrom magclass getYears getRegions -#'@importFrom rworldmap joinCountryData2Map mapCountryData #'@importFrom utils methods plotcountrymap<-function(x,hatching=FALSE,...) { - # require(methods) + if (! requireNamespace("rworldmap", quietly = TRUE)) { + stop("Package 'rworldmap' must be installed to use 'luplot::plotcountrymap()'.", call. = FALSE) + } + # require(methods) namedim<-getNames(x) if(is.null(namedim)){namedim=1} year<-getYears(x) @@ -45,14 +47,14 @@ plotcountrymap<-function(x,hatching=FALSE,...) { DF <- data.frame(country = countries,namedim = values,hatching=as.vector(x[,year,2])) dimnames(DF)[[2]][[2]] <- paste(namedim[1],substr(year,2,5)) dimnames(DF)[[2]][[3]] <- paste(namedim[2],substr(year,2,5)) - mapobject <- joinCountryData2Map(DF, joinCode = "ISO3",nameJoinColumn = "country") - mapCountryData(mapobject, nameColumnToPlot = dimnames(DF)[[2]][[2]],nameColumnToHatch=dimnames(DF)[[2]][[3]],...) + mapobject <- rworldmap::joinCountryData2Map(DF, joinCode = "ISO3",nameJoinColumn = "country") + rworldmap::mapCountryData(mapobject, nameColumnToPlot = dimnames(DF)[[2]][[2]],nameColumnToHatch=dimnames(DF)[[2]][[3]],...) } else{ DF <- data.frame(country = countries,namedim = values) dimnames(DF)[[2]][[2]] <- paste(namedim,substr(year,2,5)) - mapobject <- joinCountryData2Map(DF, joinCode = "ISO3",nameJoinColumn = "country") - mapCountryData(mapobject, nameColumnToPlot = dimnames(DF)[[2]][[2]],...) + mapobject <- rworldmap::joinCountryData2Map(DF, joinCode = "ISO3",nameJoinColumn = "country") + rworldmap::mapCountryData(mapobject, nameColumnToPlot = dimnames(DF)[[2]][[2]],...) } diff --git a/README.md b/README.md index c58d918..4c3875c 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Landuse Plot Library -R package **luplot**, version **4.0.0** +R package **luplot**, version **4.0.1** [![CRAN status](https://www.r-pkg.org/badges/version/luplot)](https://cran.r-project.org/package=luplot) [![R build status](https://github.com/pik-piam/luplot/workflows/check/badge.svg)](https://github.com/pik-piam/luplot/actions) [![codecov](https://codecov.io/gh/pik-piam/luplot/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/luplot) [![r-universe](https://pik-piam.r-universe.dev/badges/luplot)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Benjamin Bodirsky . +Bodirsky B, Dietrich J, Krause M, Stevanovic M, Humpenoeder F, Weindl I, Baumstark L, Klein D, Rolinski S, Wang X, Chen D, Sauer P (2024). _luplot: Landuse Plot Library_. R package version 4.0.1, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {luplot: Landuse Plot Library}, author = {Benjamin Leon Bodirsky and Jan Philipp Dietrich and Michael Krause and Miodrag Stevanovic and Florian Humpenoeder and Isabelle Weindl and Lavinia Baumstark and David Klein and Susanne Rolinski and Xiaoxi Wang and David Chen and Pascal Sauer}, year = {2024}, - note = {R package version 4.0.0}, + note = {R package version 4.0.1}, url = {https://github.com/pik-piam/luplot}, } ```