Skip to content

Commit 3ca8194

Browse files
authored
Merge pull request #60 from r-spatialecology/master
v1.0.1
2 parents 2fc8b78 + 46f4bdf commit 3ca8194

File tree

80 files changed

+2332
-2365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+2332
-2365
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Type: Package
22
Package: shar
33
Title: Species-Habitat Associations
4-
Version: 1.0
4+
Version: 1.0.1
55
Authors@R: c(person("Maximillian H.K.", "Hesselbarth", email = "[email protected]",
66
role = c("aut", "cre"), comment = c(ORCID = "0000-0003-1125-9918")),
77
person("Marco", "Sciaini", email = "[email protected]",

NEWS.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# shar 1.0.1
2+
* Improvements
3+
* No calculation of energy for printig (too slow)
4+
15
# shar 1.0
26
* Improvements
37
* Printing methods for most objects

R/print.rd_mar.R

-24
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#' @description Print method for rd_mar object
44
#'
55
#' @param x Random patterns.
6-
#' @param calc_energy If TRUE energy is calculated.
76
#' @param digits Number of decimal places (round).
87
#' @param ... Arguments passed to cat
98
#'
@@ -27,17 +26,13 @@
2726

2827
#' @export
2928
print.rd_mar <- function(x,
30-
calc_energy = TRUE,
3129
digits = 4,
3230
...) {
3331

3432
# set length observed pattern to 0 and
3533
# return warning that energy can't be calculated
3634
if (!spatstat::is.ppp(x$observed)) {
3735

38-
warning("Energy can not be calculated without observed pattern.",
39-
call. = FALSE)
40-
4136
number_patterns_obs <- 0
4237

4338
includes_observed <- "NA"
@@ -54,24 +49,6 @@ print.rd_mar <- function(x,
5449
# get number of randomized patterns plus observed pattern
5550
number_patterns <- length(x$randomized) + number_patterns_obs
5651

57-
# calculate energy
58-
if (calc_energy) {
59-
60-
# try to calculate energy
61-
energy <- tryCatch(expr = round(calculate_energy(x,
62-
return_mean = TRUE,
63-
verbose = FALSE),
64-
digits = digits),
65-
error = function(e) "NA")
66-
}
67-
68-
# not calculate energy
69-
else {
70-
71-
energy <- NA
72-
}
73-
74-
7552
# calculate mean iterations
7653
mean_iterations <- round(mean(unlist(x$iterations)),
7754
digits = digits)
@@ -88,7 +65,6 @@ print.rd_mar <- function(x,
8865

8966
# print result
9067
cat(paste0("No. of pattern: ", number_patterns, "\n",
91-
"Mean energy: ", energy, "\n",
9268
"Method: ", x$method, "\n",
9369
"Observed pattern: ", includes_observed, "\n",
9470
"Iterations (mean): ", mean_iterations, "\n",

R/print.rd_pat.R

+1-28
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@
33
#' @description Print method for rd_pat object
44
#'
55
#' @param x Random patterns.
6-
#' @param calc_energy If TRUE energy is calculated.
76
#' @param digits Number of decimal places (round).
8-
#' @param weights Weights used to calculate energy. The first number refers to Gest(r),
9-
#' the second number to pcf(r).
107
#' @param ... Arguments passed to cat
118
#'
129
#' @details
@@ -34,18 +31,13 @@
3431

3532
#' @export
3633
print.rd_pat <- function(x,
37-
calc_energy = TRUE,
3834
digits = 4,
39-
weights = c(0.5, 0.5),
4035
...) {
4136

4237
# set length observed pattern to 0 and
4338
# return warning that energy can't be calculated
4439
if (!spatstat::is.ppp(x$observed)) {
4540

46-
warning("Energy can not be calculated without observed pattern.",
47-
call. = FALSE)
48-
4941
number_patterns_obs <- 0
5042

5143
includes_observed <- "NA"
@@ -62,24 +54,6 @@ print.rd_pat <- function(x,
6254
# get number of randomized patterns plus observed pattern
6355
number_patterns <- length(x$randomized) + number_patterns_obs
6456

65-
# calculate energy
66-
if (calc_energy) {
67-
68-
# try to calculate energy
69-
energy <- tryCatch(expr = round(calculate_energy(x,
70-
weights = weights,
71-
return_mean = TRUE,
72-
verbose = FALSE),
73-
digits = digits),
74-
error = function(e) NA)
75-
}
76-
77-
# not calculate energy
78-
else {
79-
80-
energy <- NA
81-
}
82-
8357
# calculate mean iterations
8458
mean_iterations <- round(mean(unlist(x$iterations)),
8559
digits = digits)
@@ -90,13 +64,12 @@ print.rd_pat <- function(x,
9064

9165
if (!any(is.na(stop_criterion))) {
9266

93-
stop_criterion <- paste0(paste0(names(stop_criterion), ":", stop_criterion),
67+
stop_criterion <- paste0(paste0(names(stop_criterion), "=", stop_criterion),
9468
collapse = " ")
9569
}
9670

9771
# print result
9872
cat(paste0("No. of pattern: ", number_patterns, "\n",
99-
"Mean energy: ", energy, "\n",
10073
"Method: ", x$method, "\n",
10174
"Observed pattern: ", includes_observed, "\n",
10275
"Iterations (mean): ", mean_iterations, "\n",

README.Rmd

+3-3
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ library(shar)
4545
library(raster)
4646
```
4747

48-
**shar** comes with build-in example data sets. `species_a` and `species_b` are examplary location of species, e.g. trees, as `ppp`-objects from the `spatstat` package. `landscape` contains examplary continious environmental data. However, all methods depend on discrete data. Therefore we need to classify the data first.
48+
**shar** comes with build-in example data sets. `species_a` and `species_b` are exemplary location of species, e.g. trees, as `ppp`-objects from the `spatstat` package. `landscape` contains examplary continuous environmental data. However, all methods depend on discrete data. Therefore we need to classify the data first.
4949

5050
```{r environmental-data}
5151
landscape_classified <- classify_habitats(raster = landscape, classes = 5)
@@ -73,7 +73,7 @@ gamma_test <- fit_point_process(pattern = species_a, process = "cluster", n_rand
7373
reconstruction <- reconstruct_pattern_cluster(pattern = species_b, n_random = 39, verbose = FALSE) # takes some time
7474
```
7575

76-
Of coures, there are several utility functions. For example, you can plot a randomized pattern or calculate the differences between the observed pattern and the randomized patterns (using summary functions).
76+
Of course, there are several utility functions. For example, you can plot a randomized pattern or calculate the differences between the observed pattern and the randomized patterns (using summary functions).
7777

7878
```{r plot-random_pattern, fig.width = 5.5, fig.height = 4, fig.align = "center"}
7979
plot_randomized_pattern(reconstruction, verbose = FALSE, ask = FALSE)
@@ -83,7 +83,7 @@ plot_randomized_pattern(reconstruction, verbose = FALSE, ask = FALSE)
8383
calculate_energy(reconstruction, verbose = FALSE)
8484
```
8585

86-
The data was created that `species_a` has a negative association to habitat 4 and `species_b` has a positive association to habitat 5. At one point a posititive association to one habitat leads consequently to a negative association to another habitat (and vice versa). All this can be seen in the results.
86+
The data was created that `species_a` has a negative association to habitat 4 and `species_b` has a positive association to habitat 5. At one point a positive association to one habitat leads consequently to a negative association to another habitat (and vice versa). All this can be seen in the results.
8787

8888
```{r results}
8989
results_habitat_association(pattern = species_a, raster = torus_trans)

README.html

+34-25
Large diffs are not rendered by default.

README.md

+37-27
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ status](https://travis-ci.org/r-spatialecology/shar.svg?branch=master)](https://
77
status](https://ci.appveyor.com/api/projects/status/08hgwkr82pqb6ykq/branch/master?svg=true)](https://ci.appveyor.com/project/mhesselbarth/shar/branch/master)
88
[![Coverage
99
status](https://codecov.io/gh/r-spatialecology/shar/branch/master/graph/badge.svg)](https://codecov.io/gh/r-spatialecology/shar?branch=master)
10-
[![Project Status: Active – The project has reached a stable, usable
11-
state and is being actively
12-
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
13-
[![lifecycle](https://img.shields.io/badge/lifecycle-maturing-blue.svg)](https://www.tidyverse.org/lifecycle/#maturing)
10+
[![Project
11+
Status](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
12+
[![Lifecycle:
13+
stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://www.tidyverse.org/lifecycle/#stable)
1414
[![CRAN
1515
status](https://www.r-pkg.org/badges/version/shar)](https://cran.r-project.org/package=shar)
16-
[![](http://cranlogs.r-pkg.org/badges/grand-total/shar)](http://cran.rstudio.com/web/packages/shar/index.html)
16+
[![CRAN
17+
logs](http://cranlogs.r-pkg.org/badges/grand-total/shar)](http://cran.rstudio.com/web/packages/shar/index.html)
1718
[![License: GPL
1819
v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
1920

@@ -96,7 +97,7 @@ Plotkin et al. (2000) or pattern reconstruction (Tscheschel & Stoyan
9697
``` r
9798
gamma_test <- fit_point_process(pattern = species_a, process = "cluster", n_random = 39, verbose = FALSE)
9899

99-
reconstruction <- reconstruct_pattern(pattern = species_b, n_random = 39, verbose = FALSE) # takes some time
100+
reconstruction <- reconstruct_pattern_cluster(pattern = species_b, n_random = 39, verbose = FALSE) # takes some time
100101
```
101102

102103
Of coures, there are several utility functions. For example, you can
@@ -111,13 +112,22 @@ plot_randomized_pattern(reconstruction, verbose = FALSE, ask = FALSE)
111112

112113
``` r
113114
calculate_energy(reconstruction, verbose = FALSE)
114-
#> [1] 0.01356462 0.01867389 0.01455831 0.01754614 0.01858267 0.02008615
115-
#> [7] 0.01544740 0.01470591 0.01255234 0.01837727 0.01622154 0.01765028
116-
#> [13] 0.01517141 0.02075634 0.01836698 0.01523319 0.01832501 0.02072956
117-
#> [19] 0.01845929 0.01733616 0.01639753 0.01887276 0.01738685 0.01361427
118-
#> [25] 0.01619153 0.01695853 0.01856459 0.01692591 0.01986748 0.01604911
119-
#> [31] 0.01972613 0.01518272 0.01681647 0.02010567 0.01472619 0.01794340
120-
#> [37] 0.01740046 0.01531350 0.01869501
115+
## randomized_1 randomized_2 randomized_3 randomized_4 randomized_5
116+
## 0.01716646 0.02080741 0.02469685 0.02252225 0.01905148
117+
## randomized_6 randomized_7 randomized_8 randomized_9 randomized_10
118+
## 0.02317256 0.01467501 0.02009006 0.01796639 0.01742050
119+
## randomized_11 randomized_12 randomized_13 randomized_14 randomized_15
120+
## 0.01967685 0.01531558 0.01429541 0.02049072 0.01755755
121+
## randomized_16 randomized_17 randomized_18 randomized_19 randomized_20
122+
## 0.01672621 0.01993774 0.01695963 0.01949814 0.01368794
123+
## randomized_21 randomized_22 randomized_23 randomized_24 randomized_25
124+
## 0.02298234 0.01629161 0.02034008 0.01466430 0.02274970
125+
## randomized_26 randomized_27 randomized_28 randomized_29 randomized_30
126+
## 0.01857961 0.01489574 0.01694560 0.01860603 0.02151825
127+
## randomized_31 randomized_32 randomized_33 randomized_34 randomized_35
128+
## 0.01719001 0.01744145 0.01735466 0.01988854 0.02075585
129+
## randomized_36 randomized_37 randomized_38 randomized_39
130+
## 0.02174524 0.02042854 0.01674873 0.01900174
121131
```
122132

123133
The data was created that `species_a` has a negative association to
@@ -128,22 +138,22 @@ be seen in the results.
128138

129139
``` r
130140
results_habitat_association(pattern = species_a, raster = torus_trans)
131-
#> > Input: randomized raster | Quantile thresholds: negative < 0.025 - positive > 0.975
132-
#> habitat count lo hi significance
133-
#> 1 1 9 2 14 n.s.
134-
#> 2 2 25 9 24 positive
135-
#> 3 3 27 11 26 positive
136-
#> 4 4 0 11 29 negative
137-
#> 5 5 12 5 18 n.s.
141+
## > Input: randomized raster | Quantile thresholds: negative < 0.025 - positive > 0.975
142+
## habitat count lo hi significance
143+
## 1 1 9 2 14 n.s.
144+
## 2 2 25 9 24 positive
145+
## 3 3 27 11 26 positive
146+
## 4 4 0 11 29 negative
147+
## 5 5 12 5 18 n.s.
138148

139149
results_habitat_association(pattern = reconstruction, raster = landscape_classified)
140-
#> > Input: randomized point pattern | Quantile thresholds: negative < 0.025 - positive > 0.975
141-
#> habitat count lo hi significance
142-
#> 1 1 8 4.85 43.15 n.s.
143-
#> 2 2 22 26.80 68.10 negative
144-
#> 3 3 33 46.80 74.10 negative
145-
#> 4 4 19 29.80 69.10 negative
146-
#> 5 5 118 9.95 37.05 positive
150+
## > Input: randomized point pattern | Quantile thresholds: negative < 0.025 - positive > 0.975
151+
## habitat count lo hi significance
152+
## 1 1 8 1.00 23.35 n.s.
153+
## 2 2 22 25.85 49.10 negative
154+
## 3 3 33 40.80 68.05 negative
155+
## 4 4 19 44.00 71.10 negative
156+
## 5 5 118 20.85 60.05 positive
147157
```
148158

149159
## References

_pkgdown.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,20 @@ reference:
99
contents:
1010
- species_a
1111
- species_b
12+
- landscape
13+
- gamma_test
14+
- reconstruction
15+
- reconstruct_pattern_marks
16+
- random_walk
17+
- torus_trans
1218
- title: Randomize data
1319
contents:
1420
- fit_point_process
1521
- randomize_raster
16-
- reconstruct_marks
17-
- reconstruct_pattern
22+
- reconstruct_pattern_homo
23+
- reconstruct_pattern_hetero
24+
- reconstruct_pattern_cluster
25+
- reconstruct_pattern_marks
1826
- translate_raster
1927
- title: Analyse results
2028
contents:
@@ -30,6 +38,9 @@ reference:
3038
- estimate_pcf_fast
3139
- extract_points
3240
- rcpp_sample
41+
- print.rd_mar
42+
- print.rd_pat
43+
- print.rd_ras
3344

3445
navbar:
3546
title: shar

cran-comments.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
For details changes, please see NEWS.md.
22

3+
## shar 1.0.1
4+
Some minor improvments to existing functions
5+
36
## shar 1.0
47
New functionality and renameing/splitting of some functions
58

docs/CODE_OF_CONDUCT.html

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CONTRIBUTING.html

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/LICENSE-text.html

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/articles/background.html

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/articles/articles/publication_record.html

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)