Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions RangeShiftR/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Imports:
Rcpp (>= 1.0.0),
Rdpack (>= 0.7),
methods,
raster
Suggests:
rmarkdown,
terra
RdMacros: Rdpack
Expand Down
1 change: 1 addition & 0 deletions RangeShiftR/NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ export(readRange)
export(validateRSparams)
importFrom(Rcpp,sourceCpp)
importFrom(Rdpack,reprompt)
importFrom(methods,new)
useDynLib(RangeShiftR)
2 changes: 1 addition & 1 deletion RangeShiftR/R/RSsim.R
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,6 @@ RSsim <- function(batchnum = 1L,
if (!is.null(args$gene)) s <- s + gene
if (!is.null(args$init)) s <- s + init
# check validity
if(validObject(s)) return(s)
if(methods::validObject(s)) return(s)
else return(NULL)
}
2 changes: 1 addition & 1 deletion RangeShiftR/R/RangeShiftR.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ RangeShiftR_license <- function ()
#' @export
RangeShiftR_citation <- function ()
{
citation(package = "RangeShiftR", lib.loc = NULL, auto = NULL)
utils::citation(package = "RangeShiftR", lib.loc = NULL, auto = NULL)
}
8 changes: 4 additions & 4 deletions RangeShiftR/R/Rfunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
#----------------------

#for Integer and Numerical so that 'Integer'-slots can also accept 'Numerical' input
setClassUnion("integer_OR_numeric", c("integer", "numeric"))
methods::setClassUnion("integer_OR_numeric", c("integer", "numeric"))

#for Matrix and Numerical so that 'Matrix'-slots can also accept 'Numerical' input when 1x1-Matrix is expected
setClassUnion("matrix_OR_numeric", c("matrix", "numeric"))
methods::setClassUnion("matrix_OR_numeric", c("matrix", "numeric"))

#for cost layer to accept habitat codes or raster map file
setClassUnion("numeric_OR_character", c("numeric", "character"))
methods::setClassUnion("numeric_OR_character", c("numeric", "character"))


#-- define error and warning messages
Expand All @@ -59,4 +59,4 @@ densdep <- function(x, A0 = 1.0, alpha = 1.0, beta = 0.0) {
#' Validate a given RS parameter object
#'
#' @export
validateRSparams <- function(x){validObject(x)}
validateRSparams <- function(x){methods::validObject(x)}
2 changes: 1 addition & 1 deletion RangeShiftR/R/RunRS.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ RunRS <- function(RSparams, dirpath = getwd()){
stop("Parameter object must be of class RSparams")
}
else {
validObject(RSparams)
methods::validObject(RSparams)
}
}
if (is.null(dirpath)) {
Expand Down
26 changes: 13 additions & 13 deletions RangeShiftR/R/addition.R
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
setGeneric("+")

setMethod("+", signature(e1 = "RSparams", e2 = "SimulationParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@simul <- e2
return(e1)}
)

setMethod("+", signature(e1 = "RSparams", e2 = "LandParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
if (class(e2)[1] == "ImportedLandscape") {
if (any(e2@PatchFile=="NULL")) {
e1@control@patchmodel = FALSE
Expand Down Expand Up @@ -76,7 +76,7 @@ setMethod("+", signature(e1 = "RSparams", e2 = "LandParams"), function(e1, e2) {
)

setMethod("+", signature(e1 = "RSparams", e2 = "DemogParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@control@reproductn = e2@ReproductionType
if (class(e2@StageStruct)[1] == "StagesParams") {
e1@control@repseasons = e2@StageStruct@RepSeasons
Expand All @@ -101,15 +101,15 @@ setMethod("+", signature(e1 = "RSparams", e2 = "DemogParams"), function(e1, e2)
)

setMethod("+", signature(e1 = "DemogParams", e2 = "StagesParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@StageStruct <- e2
e1@Rmax <- -9L
e1@bc <- -9L
return(e1)}
)

setMethod("+", signature(e1 = "RSparams", e2 = "DispersalParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
if (class(e2@Transfer)[1] == "DispersalKernel") {
e1@control@transfer = 0
}
Expand All @@ -131,34 +131,34 @@ setMethod("+", signature(e1 = "RSparams", e2 = "DispersalParams"), function(e1,
)

setMethod("+", signature(e1 = "DispersalParams", e2 = "EmigrationParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@Emigration <- e2
validObject(e1)
methods::validObject(e1)
return(e1)}
)

setMethod("+", signature(e1 = "DispersalParams", e2 = "TransferParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@Transfer <- e2
validObject(e1)
methods::validObject(e1)
return(e1)}
)

setMethod("+", signature(e1 = "DispersalParams", e2 = "SettlementParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@Settlement <- e2
validObject(e1)
methods::validObject(e1)
return(e1)}
)

setMethod("+", signature(e1 = "RSparams", e2 = "GeneticsParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@gene <- e2
return(e1)}
)

setMethod("+", signature(e1 = "RSparams", e2 = "InitialisationParams"), function(e1, e2) {
validObject(e2)
methods::validObject(e2)
e1@init <- e2
return(e1)}
)
2 changes: 1 addition & 1 deletion RangeShiftR/R/class_ControlParams.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

# from RS 'CONTROL.txt' file

ControlParams <- setClass("ControlParams", slots = c(
ControlParams <- methods::setClass("ControlParams", slots = c(
#nSimuls = "integer_OR_numeric", # Not yet used by R version, in C++ version its read from parameterfile
#nLandscapes = "integer_OR_numeric", # Not yet used by R version, in C++ version its read from landfile
batchnum = "integer_OR_numeric", # only variable to set from RSsim(), optional
Expand Down
Loading