Skip to content

Commit

Permalink
Merge branch 'update-0.2.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
marcosci committed Feb 16, 2018
2 parents 92893db + 0911e40 commit e051659
Show file tree
Hide file tree
Showing 71 changed files with 152 additions and 182 deletions.
8 changes: 4 additions & 4 deletions R/NLMR.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
#' of the \emph{NLMR} package. The vignettes in this package are listed below.
#'
#' \describe{
#' \item{\href{https://marcosci.github.io/NLMR/articles/background.html}{NLM
#' \item{\href{https://marcosci.github.io/NLMR/articles/background.html/}{NLM
#' Concepts + Terminology}}{Background information on the concepts and
#' terminology that underpin the simulation of neutral landscape models.}
#' \item{\href{https://marcosci.github.io/NLMR/articles/bestiary.html}{NLMR
#' \item{\href{https://marcosci.github.io/NLMR/articles/bestiary.html/}{NLMR
#' Bestiary}}{Bestiary of the available neutral landscape models.}
#' \item{\href{https://marcosci.github.io/NLMR/articles/BasicUsageVignette.html}{
#' \item{\href{https://marcosci.github.io/NLMR/articles/getstarted.html/}{
#' Quickstart Guide}}{Short walk-through of the \emph{NLMR} package and how to
#' handle the simulations.}
#' }
Expand All @@ -21,7 +21,7 @@
# nolint start
"_PACKAGE"

globalVariables(c("value", "."))
globalVariables(c("x", "value", "."))

# nolint end
# nocov end
78 changes: 26 additions & 52 deletions R/theme_nlm.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,17 @@
#' "viridis - viridis" (= "D", the default option)
#'
#' @details
#' A focused theme to visualize raster data.
#' The theme makes use of the Roboto Condensed font (Open Source font from
#' Google) and sets a lot of defaults for the
#' A focused theme to visualize raster data that sets a lot of defaults for the
#' \code{ggplot2::theme}.
#'
#' The theme can make use of the Roboto Condensed font (Open Source font from
#' Google).
#' If your local font library does not contain Roboto as a font, you can
#' import it via \code{\link{util_import_roboto_condensed}}.
#' import it via \code{\link{util_import_roboto_condensed}} (highly recommended).
#'
#' The functions are setup in such a way that you can customize your own one by
#' just wrapping the call and changing the parameters.
#' The theme itself is heavily influenced by hrbrmstr and his great package
#' The theme itself is heavily influenced by hrbrmstr and his package
#' hrbrthemes (\url{https://github.com/hrbrmstr/hrbrthemes/}).
#'
#' @seealso \code{\link{util_import_roboto_condensed}}
Expand All @@ -53,8 +55,8 @@
#' # nolint start
#' \dontrun{
#' # simulate NLM
#' x <- NLMR::nlm_random(ncol = 75,
#' nrow = 75)
#' x <- nlm_random(ncol = 75,
#' nrow = 75)
#' # classify
#' y <- c(0.5, 0.15, 0.25)
#' y <- util_classify(x, y, c("1", "2", "3"))
Expand Down Expand Up @@ -109,26 +111,20 @@ NULL

#' @rdname theme_nlm
#' @export
theme_nlm <- function(base_family = "Roboto Condensed",
theme_nlm <- function(base_family = "serif",
base_size = 11.5,
plot_title_family = base_family,
plot_title_family = "serif",
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
subtitle_family = "serif",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
caption_family = "serif",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand All @@ -143,8 +139,7 @@ theme_nlm <- function(base_family = "Roboto Condensed",
# extend it
theme_base <- ret + ggplot2::theme(
legend.background = ggplot2::element_blank(),
legend.text = ggplot2::element_text(size = 8,
family = "Roboto Condensed Light"),
legend.text = ggplot2::element_text(size = 8),
aspect.ratio = ratio,
plot.margin = plot_margin,
strip.text = ggplot2::element_text(
Expand Down Expand Up @@ -202,26 +197,20 @@ theme_nlm <- function(base_family = "Roboto Condensed",
#' @rdname theme_nlm
#' @export
theme_nlm_discrete <- function(
base_family = "Roboto Condensed",
base_family = "serif",
base_size = 11.5,
plot_title_family = base_family,
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
subtitle_family = "serif",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
caption_family = "serif",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand All @@ -237,8 +226,7 @@ theme_nlm_discrete <- function(
# extend it
theme_base <- ret + ggplot2::theme(
legend.background = ggplot2::element_blank(),
legend.text = ggplot2::element_text(size = 8,
family = "Roboto Condensed Light"),
legend.text = ggplot2::element_text(size = 8),
aspect.ratio = ratio,
plot.margin = plot_margin,
strip.text = ggplot2::element_text(
Expand Down Expand Up @@ -301,26 +289,20 @@ theme_nlm_discrete <- function(

#' @rdname theme_nlm
#' @export
theme_nlm_grey <- function(base_family = "Roboto Condensed",
theme_nlm_grey <- function(base_family = "serif",
base_size = 11.5,
plot_title_family = base_family,
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
subtitle_family = "serif",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
caption_family = "serif",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand All @@ -335,8 +317,7 @@ theme_nlm_grey <- function(base_family = "Roboto Condensed",
# extend it
theme_base <- ret + ggplot2::theme(
legend.background = ggplot2::element_blank(),
legend.text = ggplot2::element_text(size = 8,
family = "Roboto Condensed Light"),
legend.text = ggplot2::element_text(size = 8),
aspect.ratio = ratio,
plot.margin = plot_margin,
strip.text = ggplot2::element_text(
Expand Down Expand Up @@ -394,26 +375,20 @@ theme_nlm_grey <- function(base_family = "Roboto Condensed",
#' @rdname theme_nlm
#' @export
theme_nlm_grey_discrete <-
function(base_family = "Roboto Condensed",
function(base_family = "serif",
base_size = 11.5,
plot_title_family = base_family,
plot_title_size = 18,
plot_title_face = "bold",
plot_title_margin = 10,
subtitle_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
subtitle_family = "serif",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family = if (.Platform$OS.type == "windows")
"Roboto Condensed"
else
"Roboto Condensed Light",
caption_family = "serif",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
Expand All @@ -429,8 +404,7 @@ theme_nlm_grey_discrete <-
# extend it
theme_base <- ret + ggplot2::theme(
legend.background = ggplot2::element_blank(),
legend.text = ggplot2::element_text(size = 8,
family = "Roboto Condensed Light"),
legend.text = ggplot2::element_text(size = 8),
aspect.ratio = ratio,
plot.margin = plot_margin,
strip.text = ggplot2::element_text(
Expand Down
11 changes: 6 additions & 5 deletions R/util_facetplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,16 @@
#' \dontrun{
#' l1 <- nlm_fBm(64, 64)
#' l2 <- nlm_planargradient(64, 64)
#' l3 <- nlm_mosaicfield(42, 42)
#' l3 <- nlm_randomrectangularcluster(ncol = 60, nrow = 60, minl = 5, maxl = 10)
#' l4 <- nlm_random(64, 64)
#'
#' bri1 <- raster::brick(l1, l2)
#' util_facetplot(bri1)
#'
#' lst1 <- list(lay1 = l1,
#' lay2 = l2,
#' lay3 = l3,
#' lay4 = nlm_random(70, 70))
#' lst1 <- list(layer1 = l1,
#' layer2 = l2,
#' layer3 = l3,
#' layer4 = l4)
#' util_facetplot(lst1)
#' }
#'
Expand Down
9 changes: 6 additions & 3 deletions R/zzz.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@
# https://github.com/hrbrmstr/hrbrthemes

if (.Platform$OS.type == "windows") {
if (interactive()) packageStartupMessage("Registering Windows fonts with R")
if (interactive()) packageStartupMessage(
"Registering Windows fonts with R for advanced plotting options"
)
# work around for https://github.com/wch/extrafont/issues/44
windowsFonts <- grDevices::windowsFonts
extrafont::loadfonts("win", quiet = TRUE)
}

if (interactive()) packageStartupMessage("Registering PDF &
PostScript fonts with R")
if (interactive()) packageStartupMessage(
"Registering PDF & PostScript fonts with R for advanced plotting options"
)
#work around for https://github.com/wch/extrafont/issues/44
pdfFonts <- grDevices::pdfFonts
extrafont::loadfonts("pdf", quiet = TRUE)
Expand Down
28 changes: 22 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,27 @@ Here we will provide a simple example on using `NLMR`:

``` r
library(NLMR)
#> Registering PDF &
#> PostScript fonts with R
library(magrittr)
#>
#> Attaching package: 'magrittr'
#> The following object is masked from 'package:raster':
#>
#> extract
#> The following objects are masked from 'package:testthat':
#>
#> equals, is_less_than, not
library(ggplot2) # to extend the plot functionality of NLMR
#>
#> Attaching package: 'ggplot2'
#> The following object is masked from 'package:raster':
#>
#> calc
library(SDMTools) # to calculate basic landscape metrics
#>
#> Attaching package: 'SDMTools'
#> The following object is masked from 'package:raster':
#>
#> distance

# Simulate 50x50 rectangular cluster raster
nlm_raster <- nlm_randomrectangularcluster(50,50, resolution = 1, minl = 3, maxl = 7)
Expand Down Expand Up @@ -71,9 +87,9 @@ raster::as.matrix(nlm_raster) %>%

| patchID| n.cell| n.core.cell| n.edges.perimeter| n.edges.internal| area| core.area| perimeter| perim.area.ratio| shape.index| frac.dim.index| core.area.index|
|--------:|-------:|------------:|------------------:|-----------------:|-----:|----------:|----------:|-----------------:|------------:|---------------:|----------------:|
| 0| 1245| 559| 832| 4148| 1245| 559| 832| 0.6682731| 5.859155| 1.497859| 0.4489960|
| 1| 608| 196| 580| 1852| 608| 196| 580| 0.9539474| 5.800000| 1.552761| 0.3223684|
| 2| 647| 163| 654| 1934| 647| 163| 654| 1.0108192| 6.411765| 1.574951| 0.2519320|
| 0| 1221| 622| 682| 4202| 1221| 622| 682| 0.5585586| 4.871429| 1.446019| 0.5094185|
| 1| 641| 197| 628| 1936| 641| 197| 628| 0.9797192| 6.156863| 1.564667| 0.3073323|
| 2| 638| 178| 602| 1950| 638| 178| 602| 0.9435737| 5.901961| 1.552710| 0.2789969|

Citation
--------
Expand All @@ -90,7 +106,7 @@ Citation
@Misc{,
title = {{NLMR}: Simulating neutral landscape models.},
author = {Marco Sciaini and Matthias Fritsch and Craig E. Simpkins},
note = {R package version 0.2},
note = {R package version 0.2.1},
url = {https://CRAN.R-project.org/package=NLMR},
}

Expand Down
3 changes: 1 addition & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
## Updated package

This update adds more functionality to the package and provides some additional
bug fixes.
This update fixes an error on CRAN and has small updates.

## Test environments

Expand Down
Binary file modified docs/articles/README-example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/README-example-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/articles/background.html

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

2 changes: 1 addition & 1 deletion docs/articles/bestiary.html

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

2 changes: 1 addition & 1 deletion docs/articles/faq.html

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

14 changes: 7 additions & 7 deletions docs/articles/getstarted.html

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

1 change: 1 addition & 0 deletions docs/articles/getstarted_cache/html/__packages
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
base
sp
raster
NLMR
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified docs/articles/getstarted_files/figure-html/unnamed-chunk-1-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/getstarted_files/figure-html/unnamed-chunk-2-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/getstarted_files/figure-html/unnamed-chunk-2-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/articles/getstarted_files/figure-html/unnamed-chunk-3-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/index.html

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

Loading

0 comments on commit e051659

Please sign in to comment.