Skip to content

Commit b92d329

Browse files
committed
Ran styler
Styled all the code using styler.
1 parent 2c1756a commit b92d329

17 files changed

+113
-102
lines changed

CRAN-SUBMISSION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Version: 1.3.1
2-
Date: 2024-09-19 16:57:12 UTC
3-
SHA: e1ec880c397dcaaffc861be9dfe2996f1e3741c9
1+
Version: 1.3.2
2+
Date: 2025-02-24 19:43:44 UTC
3+
SHA: 2c1756a4f864f8ae59f968b55465279ea9026a64

R/DispersalGenerator.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ DispersalGenerator <- R6Class("DispersalGenerator",
201201
}
202202
if (!self$region$use_raster || (is.logical(use_longlat) && use_longlat) ||
203203
length(grep("longlat", as.character(raster::crs(self$region$region_raster)), fixed = TRUE)) > 0) {
204-
return(earth.dist(coordinates, dist = FALSE)*1000 / self$distance_scale)
204+
return(earth.dist(coordinates, dist = FALSE) * 1000 / self$distance_scale)
205205
} else { # assume coordinates in meters
206206
if (is.na(raster::crs(self$region$region_raster))) {
207207
warning("No coordinate reference system (CRS) specified: assuming coordinates are in meters", call. = FALSE)

R/GenerativeTemplate.R

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
#' file, function and distribution templates, correlation parameters (for distribution
88
#' generation), rounding decimals, occupancy mask, and any inherited class model
99
#' attributes that need to be maintained when cloning.
10-
#'
11-
#' @examples
10+
#'
11+
#' @examples
1212
#' gen_template <- GenerativeTemplate$new()
1313
#' gen_template$occupancy_mask <- array(c(1, 1, 0, 0, 1, 1, 1))
1414
#' gen_template$decimals <- 4
1515
#' gen_template$description <- "Test generator"
16-
#'
16+
#'
1717
#' coordinates <- data.frame(x = c(1:4, 4:2), y = c(1, 1:4, 4:3))
1818
#'
1919
#' generator <- Generator$new(

R/Generator.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ Generator <- R6Class("Generator",
260260
#' @param param Name of model attribute to be read from a file.
261261
#' @param path_template Template string for the file path with placeholders
262262
#' (see \code{\link{sprintf}}) for simulation sample parameters.
263-
#' @param path_params Array of the names of the simulation sample
263+
#' @param path_params Array of the names of the simulation sample
264264
#' parameters to be substituted (in order) into the path template.
265265
#' @param file_type File type raster \emph{"GRD"} (default), \emph{"TIF"},
266266
#' \emph{"RData/RDS"}, \emph{"QS"}, or \emph{"CSV"} to be read.
@@ -270,9 +270,9 @@ Generator <- R6Class("Generator",
270270
self$file_templates[[param]] <- list()
271271
self$file_templates[[param]]$path_template <- path_template
272272
self$file_templates[[param]]$path_params <- c(path_params)
273-
if (toupper(file_type) == "GRD" || toupper(file_type) == "RDS" ||
274-
toupper(file_type) == "CSV" || toupper(file_type) == "TIF" ||
275-
toupper(file_type) == "QS"
273+
if (toupper(file_type) == "GRD" || toupper(file_type) == "RDS" ||
274+
toupper(file_type) == "CSV" || toupper(file_type) == "TIF" ||
275+
toupper(file_type) == "QS"
276276
) {
277277
self$file_templates[[param]]$file_type <- toupper(file_type)
278278
} else {

R/GenericManager.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#'
88
#' @examples
99
#' generic_manager <- GenericManager$new(
10-
#' attr1 = 22:23,
11-
#' results_filename_attributes = c("attr1", "example")
10+
#' attr1 = 22:23,
11+
#' results_filename_attributes = c("attr1", "example")
1212
#' )
1313
#' generic_manager$get_results_filename(1)
1414
#' generic_manager$get_results_filename(2)

R/SimulatorReference.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#' @description
44
#' \code{\link[R6:R6Class]{R6}} class for dynamically attaching simulator attributes
55
#' and results (passed by reference).
6-
#'
7-
#' @examples
6+
#'
7+
#' @examples
88
#' test_class <- SimulatorReference$new()
99
#' test_class$attached$attr1 <- "example1"
1010
#' test_class$results$attr1 <- "example2"

R/SpatialCorrelation.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ SpatialCorrelation <- R6Class("SpatialCorrelation",
8989
}
9090
if (!self$region$use_raster || (is.logical(use_longlat) && use_longlat) ||
9191
length(grep("longlat", as.character(raster::crs(self$region$region_raster)), fixed = TRUE)) > 0) {
92-
return(earth.dist(coordinates, dist = FALSE)*1000 / self$distance_scale)
92+
return(earth.dist(coordinates, dist = FALSE) * 1000 / self$distance_scale)
9393
} else { # assume coordinates in meters
9494
if (is.na(raster::crs(self$region$region_raster))) {
9595
warning("No coordinate reference system (CRS) specified: assuming coordinates are in meters", call. = FALSE)

R/data.R

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#'
33
#' A \emph{raster} dataset defining the grid cells of the Tasmanian study region for the
44
#' Thylacine example vignette.
5-
#'
6-
#' @examples
5+
#'
6+
#' @examples
77
#' data(tasmania_raster)
88
#' tasmania_region <- Region$new(
99
#' template_raster = tasmania_raster
@@ -27,8 +27,8 @@ NULL
2727
#' A \emph{raster} dataset (11 timesteps) defining the intensity land-use cover for each
2828
#' grid-cell in the Tasmania study region. NB. This dataset is projected and will not natively overlay
2929
#' the other \emph{raster} datasets contained in \emph{poems}.
30-
#'
31-
#' @examples
30+
#'
31+
#' @examples
3232
#' data(tasmania_raster)
3333
#' data(tasmania_modifier)
3434
#' tasmania_region <- Region$new(
@@ -54,13 +54,14 @@ NULL
5454
#' A dataset describing the nine Interim Bioregionalisation of Australia (IBRA)
5555
#' bioregions for the Tasmanian study region of the Thylacine example vignette.
5656
#'
57-
#' @examples
57+
#' @examples
5858
#' data(tasmania_ibra_data)
5959
#' data(tasmania_ibra_raster)
60-
#' raster::values(tasmania_ibra_raster)[!is.na(raster::values(tasmania_ibra_raster))] |>
61-
#' table() |> as.data.frame() |>
62-
#' merge(tasmania_ibra_data, by.x = "Var1", by.y = "index")
63-
#'
60+
#' raster::values(tasmania_ibra_raster)[!is.na(raster::values(tasmania_ibra_raster))] |>
61+
#' table() |>
62+
#' as.data.frame() |>
63+
#' merge(tasmania_ibra_data, by.x = "Var1", by.y = "index")
64+
#'
6465
#' @format A data frame with 9 rows and 4 variables:
6566
#' \describe{
6667
#' \item{index}{Cross-reference index for each bioregion}
@@ -77,8 +78,8 @@ NULL
7778
#' A \emph{raster} dataset defining the grid cells of the nine Interim
7879
#' Bioregionalisation of Australia (IBRA) bioregions for the Tasmanian study region of
7980
#' the Thylacine example vignette.
80-
#'
81-
#' @examples
81+
#'
82+
#' @examples
8283
#' data(tasmania_ibra_raster)
8384
#' data(tasmania_raster)
8485
#' tasmania_region <- Region$new(
@@ -104,10 +105,10 @@ NULL
104105
#' A \emph{raster} dataset defining estimated habitat suitability values for each grid
105106
#' cells of the Tasmanian study region of the Thylacine example vignette.
106107
#'
107-
#' @examples
108+
#' @examples
108109
#' data(thylacine_hs_raster)
109110
#' raster::plot(thylacine_hs_raster, colNA = "blue")
110-
#'
111+
#'
111112
#' @format A \emph{raster::RasterLayer} object:
112113
#' \describe{
113114
#' \item{dimensions}{32 rows by 40 columns grid}
@@ -125,15 +126,17 @@ NULL
125126
#' A dataset containing the historical record of the Thylacine bounty numbers submitted
126127
#' across the Tasmanian study region, and for each of the nine Interim Bioregionalisation
127128
#' of Australia (IBRA) bioregions for Thylacine example vignette.
128-
#'
129-
#' @examples
129+
#'
130+
#' @examples
130131
#' data(thylacine_bounty_record)
131132
#' summary(thylacine_bounty_record)
132133
#' # Assuming your data frame is named thylacine_bounty_record
133-
#' plot(thylacine_bounty_record$Year, thylacine_bounty_record$Total, type="l",
134-
#' main="Change in Total Bounties Over Time",
135-
#' xlab="Year",
136-
#' ylab="Total Bounties")
134+
#' plot(thylacine_bounty_record$Year, thylacine_bounty_record$Total,
135+
#' type = "l",
136+
#' main = "Change in Total Bounties Over Time",
137+
#' xlab = "Year",
138+
#' ylab = "Total Bounties"
139+
#' )
137140
#'
138141
#' @format A data frame with 22 rows and 11 variables:
139142
#' \describe{
@@ -159,12 +162,12 @@ NULL
159162
#' example vignette in demonstration mode. The values were obtained by running the
160163
#' vignette code for 20,000 model simulations with \code{DEMONSTRATION = FALSE}.
161164
#'
162-
#' @examples
165+
#' @examples
163166
#' data(thylacine_example_metrics)
164167
#' hist(thylacine_example_metrics$bounty_slope_error)
165168
#' hist(thylacine_example_metrics$ibra_extirpation_error)
166169
#' hist(thylacine_example_metrics$total_extinction)
167-
#'
170+
#'
168171
#' @format A data frame with 20,000 rows and 4 variables:
169172
#' \describe{
170173
#' \item{index}{Example simulation number from 1 to 20,000}
@@ -183,13 +186,13 @@ NULL
183186
#' the vignette code for 20,000 model simulations with \code{DEMONSTRATION = FALSE}.
184187
#' Note that some matrices were only stored for the selected 'best' 200 models.
185188
#'
186-
#' @examples
189+
#' @examples
187190
#' data(thylacine_example_matrices)
188191
#' data(tasmania_raster)
189192
#' region <- Region$new(template_raster = tasmania_raster)
190-
#' region$raster_from_values(thylacine_example_matrices$extirpation[1,]) |>
191-
#' raster::plot(colNA = "blue")
192-
#'
193+
#' region$raster_from_values(thylacine_example_matrices$extirpation[1, ]) |>
194+
#' raster::plot(colNA = "blue")
195+
#'
193196
#' @format A list containing the following matrices:
194197
#' \describe{
195198
#' \item{extirpation}{200 row by 795 column matrix of cell extirpation dates for the 'best' 200 models}
@@ -208,8 +211,8 @@ NULL
208211
#' Thylacine example vignette in demonstration mode. The values were obtained by running
209212
#' the vignette code for 10 replicate re-runs of the selected 'best' 200 model
210213
#' simulations with \code{DEMONSTRATION = FALSE}.
211-
#'
212-
#' @examples
214+
#'
215+
#' @examples
213216
#' data(thylacine_example_metrics_rerun)
214217
#' hist(thylacine_example_metrics_rerun$bounty_slope_error)
215218
#' hist(thylacine_example_metrics_rerun$ibra_extirpation_error)
@@ -232,8 +235,8 @@ NULL
232235
#' Thylacine example vignette in demonstration mode. The values were obtained by running
233236
#' the vignette code for 10 replicate re-runs of the selected 'best' 200 model
234237
#' simulations with \code{DEMONSTRATION = FALSE}.
235-
#'
236-
#' @examples
238+
#'
239+
#' @examples
237240
#' data(thylacine_example_matrices_rerun)
238241
#' rowMeans(thylacine_example_matrices_rerun$bounty_slope)
239242
#' rowMeans(thylacine_example_matrices_rerun$ibra_extirpation)

R/population_density.R

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@
22
#'
33
#' Modular functions for the population simulator for performing density dependent
44
#' adjustments to transition rates.
5-
#'
6-
#' @examples
5+
#'
6+
#' @examples
77
#' # Ceiling density dependence
88
#' stage_matrix <- array(c(0, 0.5, 0, 3, 0, 0.7, 4, 0, 0.8), c(3, 3))
99
#' fecundity_mask <- array(c(0, 0, 0, 1, 0, 0, 1, 0, 0), c(3, 3))
1010
#' simulator <- SimulatorReference$new()
1111
#' density_function <- population_density(
12-
#' populations = 7, stage_matrix = stage_matrix, fecundity_mask = fecundity_mask,
13-
#' fecundity_max = NULL, density_dependence = "ceiling",
14-
#' growth_rate_max = NULL, density_affects = NULL, density_stages = c(0, 1, 1),
15-
#' density_precision = NULL, simulator = simulator
12+
#' populations = 7, stage_matrix = stage_matrix, fecundity_mask = fecundity_mask,
13+
#' fecundity_max = NULL, density_dependence = "ceiling",
14+
#' growth_rate_max = NULL, density_affects = NULL, density_stages = c(0, 1, 1),
15+
#' density_precision = NULL, simulator = simulator
1616
#' )
1717
#' carrying_capacity <- rep(10, 7)
1818
#' stage_abundance <- matrix(c(
19-
#' 7, 13, 0, 26, 0, 39, 47,
20-
#' 2, 0, 6, 8, 0, 12, 13,
21-
#' 0, 3, 4, 6, 0, 9, 10
19+
#' 7, 13, 0, 26, 0, 39, 47,
20+
#' 2, 0, 6, 8, 0, 12, 13,
21+
#' 0, 3, 4, 6, 0, 9, 10
2222
#' ), nrow = 3, ncol = 7, byrow = TRUE)
23-
#'
23+
#'
2424
#' # Life cycle stages 2 and 3 (rows 2 and 3) all add up to 10 or less
2525
#' density_function(carrying_capacity, stage_abundance)
2626
#'

R/population_dispersal.R

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#'
33
#' Modular functions for the population simulator for performing dispersal of stage
44
#' abundance at a specified time step via dispersal rates provided.
5-
#'
6-
#' @examples
5+
#'
6+
#' @examples
77
#' # User-defined dispersal: one-quarter of dispersing stages move one population over
88
#' simulator <- SimulatorReference$new()
99
#' example_function <- function(params) {
@@ -12,33 +12,35 @@
1212
#' return(params$stage_abundance - emigrants + emigrants[, c(7, 1:6)])
1313
#' }
1414
#' dispersal_function <- population_dispersal(
15-
#' replicates = 4,
16-
#' time_steps = 10,
17-
#' years_per_step = 1,
18-
#' populations = 7,
19-
#' demographic_stochasticity = TRUE,
20-
#' density_stages = c(0, 1, 1),
21-
#' dispersal = example_function,
22-
#' dispersal_stages = c(0, 1, 0.5),
23-
#' dispersal_source_n_k = list(cutoff = -0.5, threshold = 1.5),
24-
#' dispersal_target_k = 5,
25-
#' dispersal_target_n = list(threshold = 10, cutoff = 15),
26-
#' simulator = simulator
15+
#' replicates = 4,
16+
#' time_steps = 10,
17+
#' years_per_step = 1,
18+
#' populations = 7,
19+
#' demographic_stochasticity = TRUE,
20+
#' density_stages = c(0, 1, 1),
21+
#' dispersal = example_function,
22+
#' dispersal_stages = c(0, 1, 0.5),
23+
#' dispersal_source_n_k = list(cutoff = -0.5, threshold = 1.5),
24+
#' dispersal_target_k = 5,
25+
#' dispersal_target_n = list(threshold = 10, cutoff = 15),
26+
#' simulator = simulator
2727
#' )
2828
#' carrying_capacity <- rep(10, 7)
2929
#' stage_abundance <- matrix(
30-
#' c(
31-
#' 7, 13, 0, 26, 0, 39, 47,
32-
#' 2, 0, 6, 8, 0, 12, 13,
33-
#' 0, 3, 4, 6, 0, 9, 10
34-
#' ),
35-
#' nrow = 3,
36-
#' ncol = 7,
37-
#' byrow = TRUE
30+
#' c(
31+
#' 7, 13, 0, 26, 0, 39, 47,
32+
#' 2, 0, 6, 8, 0, 12, 13,
33+
#' 0, 3, 4, 6, 0, 9, 10
34+
#' ),
35+
#' nrow = 3,
36+
#' ncol = 7,
37+
#' byrow = TRUE
3838
#' )
3939
#' occupied_indices <- (1:7)[-5]
40-
#' dispersal_function(r = 2, tm = 6, carrying_capacity, stage_abundance,
41-
#' occupied_indices)
40+
#' dispersal_function(
41+
#' r = 2, tm = 6, carrying_capacity, stage_abundance,
42+
#' occupied_indices
43+
#' )
4244
#'
4345
#' @param replicates Number of replicate simulation runs.
4446
#' @param time_steps Number of simulation time steps.

0 commit comments

Comments
 (0)