Skip to content

Commit

Permalink
Merge pull request #11 from reginalexavier/quickfix
Browse files Browse the repository at this point in the history
fix: compatibility with ggplot >= 3.5
  • Loading branch information
reginalexavier authored May 3, 2024
2 parents 81023eb + 9d260c4 commit 3d2fee8
Show file tree
Hide file tree
Showing 13 changed files with 48 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ inst/doc
doc
Meta
docs/

*.pdf
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ URL: https://reginalexavier.github.io/OpenLand/, https://github.com/reginalexavi
BugReports: https://github.com/reginalexavier/OpenLand/issues
Encoding: UTF-8
LazyData: true
RoxygenNote: 7.1.2
RoxygenNote: 7.3.1
Depends:
R (>= 3.4.0)
Imports:
Expand Down
3 changes: 2 additions & 1 deletion R/OpenLand-package.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"_PACKAGE"
#' OpenLand: land use and cover (LUC) time series analysis in R.
#'
#'
Expand All @@ -15,7 +16,7 @@
#' \code{\link{contingencyTable}},
#'
#' @author Reginal Exavier \email{reginalexavier@@rocketmail.com}, Peter Zeilhofer \email{zeilhoferpeter@@gmail.com}
#' @docType package
# @docType package
#' @name OpenLand-package
#' @aliases OpenLand
#'
Expand Down
4 changes: 2 additions & 2 deletions R/demolandscape.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#' Create Raster with Random pixel Value
#'
#' This function create a raster serie with some setup like the layer name and
#' This function creates a raster series with some setup like the layer name and
#' the sample value for the lulc
#'
#' @param year numeric. A vector of year, first and last included.
Expand All @@ -13,7 +13,7 @@
#' @param ymx numeric. y maximum extent.
#' @param crs character. the coordinate referencing system.
#' @param category A numeric vector of the raster categories.
#' @param prob A numreric vector of the probability of occurrence for the
#' @param prob A numeric vector of the probability of occurrence for the
#' category list.
#'
#'
Expand Down
12 changes: 6 additions & 6 deletions R/generalfunctions.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

#' Summary of multiple parameters in a raster directory
#'
#' Listing major charateristics of raster inputs. Those characteristics are the
#' Listing major characteristics of raster inputs. Those characteristics are the
#' dimensions, the resolution, the extent, the values (min, max) and the
#' coordinate reference system.
#'
Expand All @@ -24,10 +24,10 @@
#'
summary_dir <- function(path) {

if ((class(path) == "list") &
(c(class(path[[1]])) == "RasterLayer")) {
if (inherits(path, "list") &
inherits(path[[1]], "RasterLayer")) {
layer_list <- path
} else if (class(path) == "character") {
} else if (inherits(path, "character")) {

raster_files <-
list.files(path,
Expand Down Expand Up @@ -87,8 +87,8 @@ summary_dir <- function(path) {
#'
summary_map <- function(path) {
rastermap <-
if (class(path) != "character") {
if (class(path) == "RasterLayer") {
if (!inherits(path, "character")) {
if (inherits(path, "RasterLayer")) {
path
} else {
path[[1]]
Expand Down
2 changes: 1 addition & 1 deletion R/otherplots.R
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ netgrossplot <-
)) +
scale_fill_manual(values = color) +
labs(fill = legend_title) +
geom_hline(yintercept = 0, size = .3) +
geom_hline(yintercept = 0, linewidth = .3) +
xlab(xlab) +
ylab(ylab) +
ggtitle(title) +
Expand Down
20 changes: 10 additions & 10 deletions R/plotMethods.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ methods::setMethod(
) +
geom_hline(aes(yintercept = dataset[[4]], color = "U"),
linetype = 5,
size = .5) +
geom_hline(aes(yintercept = 0), size = .01) +
linewidth = .5) +
geom_hline(aes(yintercept = 0), linewidth = .01) +
scale_fill_manual(values = c(color_bar[[1]], color_bar[[2]])) +
ylab(NULL) +
scale_color_manual(values = "black") +
Expand All @@ -97,7 +97,7 @@ methods::setMethod(
xend = (length(unique(dataset[[1]])) / 2) + leg_curv[[2]],
yend = dataset[[4]] + leg_curv[[1]]
),
size = .6,
linewidth = .6,
curvature = .1,
arrow = arrow(length = unit(2, "mm"), ends = "first")
) +
Expand Down Expand Up @@ -140,7 +140,7 @@ methods::setMethod(
coord_flip() +
xlab(expression(paste("Periodo de tempo [ ", Y[t], ",", Y[t + 1], "]"))) +
ylab(NULL) +
geom_hline(aes(yintercept = 0), size = .01) +
geom_hline(aes(yintercept = 0), linewidth = .01) +
scale_y_reverse(expand = expansion(mult = c(0.01, 0))) +
scale_x_discrete(position = "top", expand = expansion(mult = c(0.06, 0.06))) +
theme(
Expand Down Expand Up @@ -231,10 +231,10 @@ methods::setMethod(
levels(dataset[[2]])))]])) +
xlab(NULL) +
ylab(NULL) +
geom_hline(aes(yintercept = 0), size = .3) +
geom_hline(aes(yintercept = 0), linewidth = .3) +
geom_hline(aes(yintercept = dataset[[6]], color = names(dataset)[[6]]),
linetype = 5,
size = .3) +
linewidth = .3) +
scale_color_manual(values = "black") +
coord_flip() +
labs(fill = labs[[1]], colour = labs[[2]]) +
Expand Down Expand Up @@ -290,7 +290,7 @@ methods::setMethod(
levels(dataset[[2]])))]])) +
xlab(NULL) +
ylab(NULL) +
geom_hline(aes(yintercept = 0), size = .3) +
geom_hline(aes(yintercept = 0), linewidth = .3) +
coord_flip() +
labs(fill = "Categories") +
scale_y_reverse(expand = expansion(mult = c(0.01, 0))) +
Expand Down Expand Up @@ -390,10 +390,10 @@ methods::setMethod(
levels(dataset[[2]])))]])) +
xlab(NULL) +
ylab(NULL) +
geom_hline(aes(yintercept = 0), size = .3) +
geom_hline(aes(yintercept = 0), linewidth = .3) +
geom_hline(aes(yintercept = dataset[[7]], color = names(dataset)[[7]]),
linetype = 5,
size = .3) +
linewidth = .3) +
scale_color_manual(values = "black") +
coord_flip() +
labs(fill = labs[[1]], colour = labs[[2]]) +
Expand Down Expand Up @@ -448,7 +448,7 @@ methods::setMethod(
levels(dataset[[2]])))]])) +
xlab(NULL) +
ylab(NULL) +
geom_hline(aes(yintercept = 0), size = .3) +
geom_hline(aes(yintercept = 0), linewidth = .3) +
coord_flip() +
labs(fill = "Categories") +
scale_y_reverse(expand = expansion(mult = c(0.01, 0))) +
Expand Down
1 change: 0 additions & 1 deletion man/OpenLand-package.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/dot-demo_landscape.Rd

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

2 changes: 1 addition & 1 deletion man/summary_dir.Rd

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

26 changes: 16 additions & 10 deletions tests/testthat/test_generalfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,25 @@ test_that("Behavior of acc_changes", {
})


# testFolder <- tempdir()
#
# lapply(.demo_landscape(year = 2000:2004), function(x)
# raster::writeRaster(x,
# filename = file.path(testFolder, paste0(names(x), ".tif")),
# datatype = 'INT1U',
# overwrite = TRUE
# ))
if (FALSE){
testFolder <- tempdir()

lapply(.demo_landscape(year = 2000:2004), function(x)
raster::writeRaster(x,
filename = file.path(testFolder, paste0(names(x), ".tif")),
datatype = 'INT1U',
overwrite = TRUE
))

expect_silent(summary_dir(testFolder))
expect_equal(nrow(summary_dir(testFolder)), 5)

}


test_that("Behavior of summary_dir", {

# expect_silent(summary_dir(testFolder))
# expect_equal(nrow(summary_dir(testFolder)), 5)

expect_silent(summary_dir(demo_raster))
expect_visible(summary_dir(demo_raster))
expect_error(summary_dir(raster::stack(demo_raster)))
Expand Down
5 changes: 4 additions & 1 deletion tests/testthat/test_plots.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,14 @@ test_that("Behavior of the other plots", {
expect_visible(sankeyLand(demo_cont$lulc_Multistep, demo_cont$tb_legend))


expect_output(str(barplotLand(demo_cont$lulc_Multistep, demo_cont$tb_legend)), "List of 11")
expect_output(str(netgrossplot(demo_cont$lulc_Multistep, demo_cont$tb_legend)), "List of 11")
expect_s3_class(barplotLand(demo_cont$lulc_Multistep, demo_cont$tb_legend), "ggplot")
#expect_null(str(chordDiagramLand(demo_cont$lulc_Onestep, demo_cont$tb_legend)))
# expect_type(str(chordDiagramLand(demo_cont$lulc_Onestep, demo_cont$tb_legend)), "NULL")
expect_s3_class(netgrossplot(demo_cont$lulc_Multistep, demo_cont$tb_legend), "ggplot")
expect_output(str(sankeyLand(demo_cont$lulc_Onestep, demo_cont$tb_legend)), "List of 8")
expect_output(str(sankeyLand(demo_cont$lulc_Multistep, demo_cont$tb_legend)), "List of 8")


})

4 changes: 2 additions & 2 deletions vignettes/openland_vignette.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: "Quick introduction to the OpenLand package"
output: rmarkdown::html_vignette
bibliography: papers_OpenLand.bib
vignette: >
%\VignetteIndexEntry{Quick Intro for OpenLand Package}
%\VignetteIndexEntry{Quick introduction to the OpenLand package}
%\VignetteEngine{knitr::rmarkdown}
%\VignetteEncoding{UTF-8}
---
Expand Down Expand Up @@ -90,7 +90,7 @@ For our study area, `contingenceTable(input_raster = SaoLourencoBasin, pixelreso

```{r}
# SL_2002_2014 <- contingenceTable(input_raster = SaoLourencoBasin, pixelresolution = 30)
# SL_2002_2014 <- contingencyTable(input_raster = SaoLourencoBasin, pixelresolution = 30)
SL_2002_2014
Expand Down

0 comments on commit 3d2fee8

Please sign in to comment.