From 15a151b506e584f73d1a9f298b65dbb651f4c5e3 Mon Sep 17 00:00:00 2001 From: sgvignali <22011122+sgvignali@users.noreply.github.com> Date: Thu, 22 Jun 2023 17:23:04 +0200 Subject: [PATCH] Remove empty lines --- R/SDMmodel2MaxEnt.R | 10 ++++------ R/auc.R | 5 +---- R/doJk.R | 6 ++---- R/gridSearch.R | 6 ++---- R/maxentTh.R | 6 ++---- R/maxentVarImp.R | 6 ++---- R/modelReport.R | 10 ++++------ R/optimizeModel.R | 7 ++----- R/plotCor.R | 6 ++---- R/plotJk.R | 6 ++---- R/plotPA.R | 16 ++++++---------- R/plotPred.R | 10 ++++------ R/plotROC.R | 4 ++-- R/predict-SDMmodel.R | 3 +-- R/predict-SDMmodelCV.R | 13 +++++-------- R/randomSearch.R | 6 ++---- R/reduceVar.R | 7 ++----- R/swd2csv.R | 7 ++----- R/thinData.R | 6 ++---- R/train.R | 9 +++------ R/tss.R | 10 ++++------ R/varImp.R | 6 ++---- R/varSel.R | 7 ++----- man/SDMmodel2MaxEnt.Rd | 7 ++----- man/auc.Rd | 5 +---- man/doJk.Rd | 6 ++---- man/gridSearch.Rd | 6 ++---- man/maxentTh.Rd | 6 ++---- man/maxentVarImp.Rd | 6 ++---- man/modelReport.Rd | 10 ++++------ man/optimizeModel.Rd | 7 ++----- man/plotCor.Rd | 6 ++---- man/plotJk.Rd | 6 ++---- man/plotPA.Rd | 16 ++++++---------- man/plotPred.Rd | 10 ++++------ man/plotROC.Rd | 1 - man/predict-SDMmodel-method.Rd | 3 +-- man/predict-SDMmodelCV-method.Rd | 13 +++++-------- man/randomSearch.Rd | 6 ++---- man/reduceVar.Rd | 7 ++----- man/swd2csv.Rd | 7 ++----- man/thinData.Rd | 6 ++---- man/train.Rd | 9 +++------ man/tss.Rd | 10 ++++------ man/varImp.Rd | 6 ++---- man/varSel.Rd | 7 ++----- 46 files changed, 116 insertions(+), 222 deletions(-) diff --git a/R/SDMmodel2MaxEnt.R b/R/SDMmodel2MaxEnt.R index fdfae75c..e2d64ce6 100644 --- a/R/SDMmodel2MaxEnt.R +++ b/R/SDMmodel2MaxEnt.R @@ -9,9 +9,10 @@ #' @export #' @importFrom dismo maxent #' +#' @author Sergio Vignali +#' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -35,10 +36,7 @@ #' fc = "l") #' #' dismo_model <- SDMmodel2MaxEnt(model) -#' dismo_model -#' } -#' -#' @author Sergio Vignali +#' dismo_model} SDMmodel2MaxEnt <- function(model) { if (!inherits(model@model, "Maxent")) diff --git a/R/auc.R b/R/auc.R index c7ae506f..dd311297 100644 --- a/R/auc.R +++ b/R/auc.R @@ -63,11 +63,9 @@ #' # Compute the testing AUC #' auc(model, #' test = test) -#' #' \donttest{ #' # Same example but using cross validation instead of training and testing #' # datasets -#' # Create the folds #' folds <- randomFolds(data, #' k = 4, #' only_presence = TRUE) @@ -86,8 +84,7 @@ #' #' # Compute the AUC for the held apart testing dataset #' auc(model, -#' test = test) -#' } +#' test = test)} auc <- function(model, test = NULL) { diff --git a/R/doJk.R b/R/doJk.R index a9ee0784..7f5d4986 100644 --- a/R/doJk.R +++ b/R/doJk.R @@ -24,8 +24,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -94,8 +93,7 @@ #' #' jk$results #' jk$models_without -#' jk$models_withonly -#' } +#' jk$models_withonly} doJk <- function(model, metric, variables = NULL, diff --git a/R/gridSearch.R b/R/gridSearch.R index ff9fb75a..3b01ced0 100644 --- a/R/gridSearch.R +++ b/R/gridSearch.R @@ -35,8 +35,7 @@ #' @seealso \link{randomSearch} and \link{optimizeModel}. #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -89,8 +88,7 @@ #' metric = "aicc", #' env = predictors, #' save_models = FALSE) -#' output@results -#' } +#' output@results} gridSearch <- function(model, hypers, metric, diff --git a/R/maxentTh.R b/R/maxentTh.R index a9867a76..19c4462a 100644 --- a/R/maxentTh.R +++ b/R/maxentTh.R @@ -12,8 +12,7 @@ #' @seealso \link{maxentVarImp}. #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -36,8 +35,7 @@ #' data = data, #' fc = "l") #' -#' maxentTh(model) -#' } +#' maxentTh(model)} maxentTh <- function(model) { if (!inherits(model@model, "Maxent")) diff --git a/R/maxentVarImp.R b/R/maxentVarImp.R index 0f0c333d..e9fecba5 100644 --- a/R/maxentVarImp.R +++ b/R/maxentVarImp.R @@ -18,8 +18,7 @@ #' @seealso \link{maxentTh}. #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -44,8 +43,7 @@ #' data = data, #' fc = "l") #' -#' maxentVarImp(model) -#' } +#' maxentVarImp(model)} maxentVarImp <- function(model) { if (.get_model_class(model) != "Maxent") diff --git a/R/modelReport.R b/R/modelReport.R index c56b2726..aa227e95 100644 --- a/R/modelReport.R +++ b/R/modelReport.R @@ -28,9 +28,9 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # If you run the following examples with the function example(), you may want -#' # to set the argument ask like following: example("modelReport", ask = FALSE) +#' \donttest{# If you run the following examples with the function example(), +#' # you may want to set the argument ask like following: example("modelReport", +#' # ask = FALSE) #' # Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", @@ -71,9 +71,7 @@ #' only_presence = TRUE, #' jk = TRUE, #' env = predictors, -#' permut = 2) -#' } -#' } +#' permut = 2)}} modelReport <- function(model, folder, test = NULL, diff --git a/R/optimizeModel.R b/R/optimizeModel.R index d0f275b3..33189a49 100644 --- a/R/optimizeModel.R +++ b/R/optimizeModel.R @@ -43,8 +43,7 @@ #' @seealso \link{gridSearch} and \link{randomSearch}. #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -90,9 +89,7 @@ #' seed = 798) #' output@results #' output@models -#' output@models[[1]] # Best model -#' } -#' } +#' output@models[[1]] # Best model}} optimizeModel <- function(model, hypers, metric, diff --git a/R/plotCor.R b/R/plotCor.R index c6ffe0fd..d30836d8 100644 --- a/R/plotCor.R +++ b/R/plotCor.R @@ -19,8 +19,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -50,8 +49,7 @@ #' plotCor(bg, #' method = "spearman", #' cor_th = 0.8, -#' text_size = 4) -#' } +#' text_size = 4)} plotCor <- function(bg, method = "spearman", cor_th = NULL, diff --git a/R/plotJk.R b/R/plotJk.R index 83c8140b..83f1a079 100644 --- a/R/plotJk.R +++ b/R/plotJk.R @@ -17,8 +17,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -62,8 +61,7 @@ #' #' # Plot Jackknife test result for testing #' plotJk(jk, #' type = "test", -#' ref = auc(model, test = test)) -#' } +#' ref = auc(model, test = test))} plotJk <- function(jk, type = c("train", "test"), ref = NULL) { diff --git a/R/plotPA.R b/R/plotPA.R index baf0f2be..0a2251dc 100644 --- a/R/plotPA.R +++ b/R/plotPA.R @@ -24,10 +24,9 @@ #' @seealso \link{plotPred}. #' #' @examples -#' \donttest{ -#' map <- terra::rast(matrix(runif(400, 0, 1), -#' nrow = 20, -#' ncol = 20)) +#' \donttest{map <- terra::rast(matrix(runif(400, 0, 1), +#' nrow = 20, +#' ncol = 20)) #' plotPA(map, #' th = 0.8) #' @@ -36,15 +35,12 @@ #' th = 0.5, #' colors = c("#d8b365", "#018571")) #' -#' # Save the file #' \dontrun{ -#' # The following command will save the map in the working directory. Note that -#' # the filename must include the extension +#' # Save the file. The following command will save the map in the working +#' # directory. Note that `filename` must include the extension. #' plotPA(map, #' th = 0.7, -#' filename = "my_map.tif") -#' } -#' } +#' filename = "my_map.tif")}} plotPA <- function(map, th, colors = NULL, diff --git a/R/plotPred.R b/R/plotPred.R index 69c81ccb..62b032de 100644 --- a/R/plotPred.R +++ b/R/plotPred.R @@ -18,10 +18,9 @@ #' @seealso \link{plotPA}. #' #' @examples -#' \donttest{ -#' map <- terra::rast(matrix(runif(400, 0, 1), -#' nrow = 20, -#' ncol= 20)) +#' \donttest{map <- terra::rast(matrix(runif(400, 0, 1), +#' nrow = 20, +#' ncol= 20)) #' #' plotPred(map, #' lt = "Habitat suitability \ncloglog") @@ -29,8 +28,7 @@ #' # Custom colors #' plotPred(map, #' lt = "Habitat suitability", -#' colorramp = c("#2c7bb6", "#ffffbf", "#d7191c")) -#' } +#' colorramp = c("#2c7bb6", "#ffffbf", "#d7191c"))} plotPred <- function(map, lt = "", colorramp = NULL, diff --git a/R/plotROC.R b/R/plotROC.R index 411a5e1f..987ffb6e 100644 --- a/R/plotROC.R +++ b/R/plotROC.R @@ -10,6 +10,8 @@ #' @importFrom rlang .data #' @importFrom ggplot2 ggplot aes #' +#' @author Sergio Vignali +#' #' @examples #' # Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), @@ -47,8 +49,6 @@ #' # Plot the training and testing ROC curves #' plotROC(model, #' test = test) -#' -#' @author Sergio Vignali plotROC <- function(model, test = NULL) { diff --git a/R/predict-SDMmodel.R b/R/predict-SDMmodel.R index 1c3a1f2b..af4f02d9 100644 --- a/R/predict-SDMmodel.R +++ b/R/predict-SDMmodel.R @@ -101,8 +101,7 @@ setGeneric("predict", function(object, ...) #' predict(model, #' data = predictors, #' type = "logistic", -#' filename = "my_map.tif") -#' } +#' filename = "my_map.tif")} setMethod( f = "predict", signature = "SDMmodel", diff --git a/R/predict-SDMmodelCV.R b/R/predict-SDMmodelCV.R index a4a0881e..cccb41e8 100644 --- a/R/predict-SDMmodelCV.R +++ b/R/predict-SDMmodelCV.R @@ -59,8 +59,7 @@ #' values from a lambdas file. #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -97,10 +96,10 @@ #' #' # Make cloglog prediction for the whole study area, get the average, standard #' # deviation, and maximum values of the k models, and save the output in three -#' # files -#' \dontrun{ +#' # files. #' # The following commands save the output in the working directory. Note that -#' # the filename must include the extension +#' # the `filename` must include the extension +#' \dontrun{ #' maps <- predict(model, #' data = predictors, #' fun = c("mean", "sd", "max"), @@ -119,9 +118,7 @@ #' data = predictors, #' fun = "sd", #' type = "logistic", -#' filename = "my_map.tif") -#' } -#' } +#' filename = "my_map.tif")}} setMethod( f = "predict", signature = "SDMmodelCV", diff --git a/R/randomSearch.R b/R/randomSearch.R index 56e77606..318e7125 100644 --- a/R/randomSearch.R +++ b/R/randomSearch.R @@ -32,8 +32,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -78,8 +77,7 @@ #' output@models #' #' # Order results by highest test AUC -#' output@results[order(-output@results$test_AUC), ] -#' } +#' output@results[order(-output@results$test_AUC), ]} randomSearch <- function(model, hypers, metric, diff --git a/R/reduceVar.R b/R/reduceVar.R index 21e85864..90200016 100644 --- a/R/reduceVar.R +++ b/R/reduceVar.R @@ -34,8 +34,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -101,9 +100,7 @@ #' th = 2, #' metric = "auc", #' test = test, -#' use_pc = TRUE) -#' } -#' } +#' use_pc = TRUE)}} reduceVar <- function(model, th, metric, diff --git a/R/swd2csv.R b/R/swd2csv.R index 41da6aaa..c08af5c1 100644 --- a/R/swd2csv.R +++ b/R/swd2csv.R @@ -20,8 +20,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -46,9 +45,7 @@ #' #' # Save the SWD object in two separate csv files #' swd2csv(data, -#' file_name = c("presence.csv", "absence.csv")) -#' } -#' } +#' file_name = c("presence.csv", "absence.csv"))}} swd2csv <- function(swd, file_name) { diff --git a/R/thinData.R b/R/thinData.R index 5d91c290..8f8c80a6 100644 --- a/R/thinData.R +++ b/R/thinData.R @@ -27,8 +27,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -81,8 +80,7 @@ #' env = predictors, #' x = "X", #' y = "Y") -#' head(data) -#' } +#' head(data)} thinData <- function(coords, env, x = "x", diff --git a/R/train.R b/R/train.R index 1ef3a34b..e869d9b5 100644 --- a/R/train.R +++ b/R/train.R @@ -98,8 +98,7 @@ #' cross-validation. \url{https://github.com/rvalavi/blockCV}. #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -194,8 +193,7 @@ #' data = data, #' fc = "l", #' reg = 0.8, -#' folds = spatial_folds) -#' } +#' folds = spatial_folds)} #' #' ## Train presence absence models #' # Prepare presence and absence locations @@ -238,8 +236,7 @@ #' ntree = 300, #' n.trees = 300, #' shrinkage = 0.001) -#' output -#' } +#' output} train <- function(method, data, folds = NULL, diff --git a/R/tss.R b/R/tss.R index e4278885..af865ff8 100644 --- a/R/tss.R +++ b/R/tss.R @@ -64,10 +64,9 @@ #' tss(model, #' test = test) #' -#' \donttest{ -#' # Same example but using cross validation instead of training and testing -#' # datasets -#' # Create 4 random folds splitting only the presence locations +#' \donttest{# Same example but using cross validation instead of training and +#' # testing datasets. Create 4 random folds splitting only the presence +#' # locations #' folds = randomFolds(train, #' k = 4, #' only_presence = TRUE) @@ -86,8 +85,7 @@ #' #' # Compute the TSS for the held apart testing dataset #' tss(model, -#' test = test) -#' } +#' test = test)} tss <- function(model, test = NULL) { diff --git a/R/varImp.R b/R/varImp.R index 40713447..58fb1866 100644 --- a/R/varImp.R +++ b/R/varImp.R @@ -25,8 +25,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -76,8 +75,7 @@ #' # Compute variable importance #' vi <- varImp(model, #' permut = 5) -#' vi -#' } +#' vi} varImp <- function(model, permut = 10, progress = TRUE) { diff --git a/R/varSel.R b/R/varSel.R index 584ba282..6e86df01 100644 --- a/R/varSel.R +++ b/R/varSel.R @@ -44,8 +44,7 @@ #' @author Sergio Vignali #' #' @examples -#' \donttest{ -#' # Acquire environmental variables +#' \donttest{# Acquire environmental variables #' files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), #' pattern = "grd", #' full.names = TRUE) @@ -126,9 +125,7 @@ #' cor_th = 0.7, #' use_pc = TRUE, #' env = predictors) -#' vs -#' } -#' } +#' vs}} varSel <- function(model, metric, bg4cor, diff --git a/man/SDMmodel2MaxEnt.Rd b/man/SDMmodel2MaxEnt.Rd index 683eaa84..5043e70e 100644 --- a/man/SDMmodel2MaxEnt.Rd +++ b/man/SDMmodel2MaxEnt.Rd @@ -17,8 +17,7 @@ Converts an \linkS4class{SDMmodel} object containing a \linkS4class{Maxent} model into a dismo \linkS4class{MaxEnt} object. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -42,9 +41,7 @@ model <- train(method = "Maxent", fc = "l") dismo_model <- SDMmodel2MaxEnt(model) -dismo_model -} - +dismo_model} } \author{ Sergio Vignali diff --git a/man/auc.Rd b/man/auc.Rd index 3bf2cd14..16aa8208 100644 --- a/man/auc.Rd +++ b/man/auc.Rd @@ -64,11 +64,9 @@ auc(model) # Compute the testing AUC auc(model, test = test) - \donttest{ # Same example but using cross validation instead of training and testing # datasets -# Create the folds folds <- randomFolds(data, k = 4, only_presence = TRUE) @@ -87,8 +85,7 @@ auc(model, # Compute the AUC for the held apart testing dataset auc(model, - test = test) -} + test = test)} } \references{ Mason, S. J. and Graham, N. E. (2002), Areas beneath the relative diff --git a/man/doJk.Rd b/man/doJk.Rd index 330a62f8..329fac61 100644 --- a/man/doJk.Rd +++ b/man/doJk.Rd @@ -46,8 +46,7 @@ returns a list containing the test results together with the models. Run the Jackknife test for variable importance removing one variable at time. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -116,8 +115,7 @@ jk <- doJk(model, jk$results jk$models_without -jk$models_withonly -} +jk$models_withonly} } \author{ Sergio Vignali diff --git a/man/gridSearch.Rd b/man/gridSearch.Rd index c31006c0..7e746d86 100644 --- a/man/gridSearch.Rd +++ b/man/gridSearch.Rd @@ -55,8 +55,7 @@ An interactive chart showing in real-time the steps performed by the algorithm is displayed in the Viewer pane. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -109,8 +108,7 @@ output <- gridSearch(model, metric = "aicc", env = predictors, save_models = FALSE) -output@results -} +output@results} } \seealso{ \link{randomSearch} and \link{optimizeModel}. diff --git a/man/maxentTh.Rd b/man/maxentTh.Rd index 7be4adbc..af522826 100644 --- a/man/maxentTh.Rd +++ b/man/maxentTh.Rd @@ -16,8 +16,7 @@ data.frame with the thresholds. Returns the value of the thresholds generated by the MaxEnt software. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -40,8 +39,7 @@ model <- train(method = "Maxent", data = data, fc = "l") -maxentTh(model) -} +maxentTh(model)} } \seealso{ \link{maxentVarImp}. diff --git a/man/maxentVarImp.Rd b/man/maxentVarImp.Rd index 7def78e6..9fda90d5 100644 --- a/man/maxentVarImp.Rd +++ b/man/maxentVarImp.Rd @@ -23,8 +23,7 @@ the output is the average of the variable importance of each model trained during the cross validation. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -49,8 +48,7 @@ model <- train(method = "Maxent", data = data, fc = "l") -maxentVarImp(model) -} +maxentVarImp(model)} } \seealso{ \link{maxentTh}. diff --git a/man/modelReport.Rd b/man/modelReport.Rd index 70b048bd..05b2fed0 100644 --- a/man/modelReport.Rd +++ b/man/modelReport.Rd @@ -55,9 +55,9 @@ The function produces a report similar to the one created by MaxEnt software. See \pkg{terra} documentation to see how to pass factors. } \examples{ -\donttest{ -# If you run the following examples with the function example(), you may want -# to set the argument ask like following: example("modelReport", ask = FALSE) +\donttest{# If you run the following examples with the function example(), +# you may want to set the argument ask like following: example("modelReport", +# ask = FALSE) # Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", @@ -98,9 +98,7 @@ modelReport(model, only_presence = TRUE, jk = TRUE, env = predictors, - permut = 2) -} -} + permut = 2)}} } \author{ Sergio Vignali diff --git a/man/optimizeModel.Rd b/man/optimizeModel.Rd index 3aaa4c5f..a7509d03 100644 --- a/man/optimizeModel.Rd +++ b/man/optimizeModel.Rd @@ -74,8 +74,7 @@ Part of the code is inspired by \href{https://blog.coast.ai/lets-evolve-a-neural-network-with-a-geneticalgorithm-code-included-8809bece164}{this post}. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -121,9 +120,7 @@ output <- optimizeModel(model, seed = 798) output@results output@models -output@models[[1]] # Best model -} -} +output@models[[1]] # Best model}} } \seealso{ \link{gridSearch} and \link{randomSearch}. diff --git a/man/plotCor.Rd b/man/plotCor.Rd index b73fd093..0d6ef024 100644 --- a/man/plotCor.Rd +++ b/man/plotCor.Rd @@ -26,8 +26,7 @@ prints only the coefficients that are higher or lower than the given threshold. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -57,8 +56,7 @@ plotCor(bg, plotCor(bg, method = "spearman", cor_th = 0.8, - text_size = 4) -} + text_size = 4)} } \author{ Sergio Vignali diff --git a/man/plotJk.Rd b/man/plotJk.Rd index 356b35fb..7cb9ee27 100644 --- a/man/plotJk.Rd +++ b/man/plotJk.Rd @@ -23,8 +23,7 @@ A \link[ggplot2]{ggplot} object. Plot the Jackknife Test for variable importance. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -68,8 +67,7 @@ plotJk(jk, #' # Plot Jackknife test result for testing plotJk(jk, type = "test", - ref = auc(model, test = test)) -} + ref = auc(model, test = test))} } \author{ Sergio Vignali diff --git a/man/plotPA.Rd b/man/plotPA.Rd index be99da70..b7ea91b8 100644 --- a/man/plotPA.Rd +++ b/man/plotPA.Rd @@ -42,10 +42,9 @@ A \link[ggplot2]{ggplot} object. Plot a presence absence map using the given threshold. } \examples{ -\donttest{ -map <- terra::rast(matrix(runif(400, 0, 1), - nrow = 20, - ncol = 20)) +\donttest{map <- terra::rast(matrix(runif(400, 0, 1), + nrow = 20, + ncol = 20)) plotPA(map, th = 0.8) @@ -54,15 +53,12 @@ plotPA(map, th = 0.5, colors = c("#d8b365", "#018571")) -# Save the file \dontrun{ -# The following command will save the map in the working directory. Note that -# the filename must include the extension +# Save the file. The following command will save the map in the working +# directory. Note that `filename` must include the extension. plotPA(map, th = 0.7, - filename = "my_map.tif") -} -} + filename = "my_map.tif")}} } \seealso{ \link{plotPred}. diff --git a/man/plotPred.Rd b/man/plotPred.Rd index bb45d085..0f531b48 100644 --- a/man/plotPred.Rd +++ b/man/plotPred.Rd @@ -23,10 +23,9 @@ A \link[ggplot2]{ggplot} object. Plot Prediction output. } \examples{ -\donttest{ -map <- terra::rast(matrix(runif(400, 0, 1), - nrow = 20, - ncol= 20)) +\donttest{map <- terra::rast(matrix(runif(400, 0, 1), + nrow = 20, + ncol= 20)) plotPred(map, lt = "Habitat suitability \ncloglog") @@ -34,8 +33,7 @@ plotPred(map, # Custom colors plotPred(map, lt = "Habitat suitability", - colorramp = c("#2c7bb6", "#ffffbf", "#d7191c")) -} + colorramp = c("#2c7bb6", "#ffffbf", "#d7191c"))} } \seealso{ \link{plotPA}. diff --git a/man/plotROC.Rd b/man/plotROC.Rd index f84fc3fb..66a4cf75 100644 --- a/man/plotROC.Rd +++ b/man/plotROC.Rd @@ -54,7 +54,6 @@ plotROC(model) # Plot the training and testing ROC curves plotROC(model, test = test) - } \author{ Sergio Vignali diff --git a/man/predict-SDMmodel-method.Rd b/man/predict-SDMmodel-method.Rd index be62987c..9fd7c047 100644 --- a/man/predict-SDMmodel-method.Rd +++ b/man/predict-SDMmodel-method.Rd @@ -117,8 +117,7 @@ predict(model, predict(model, data = predictors, type = "logistic", - filename = "my_map.tif") -} + filename = "my_map.tif")} } \references{ Wilson P.D., (2009). Guidelines for computing MaxEnt model output diff --git a/man/predict-SDMmodelCV-method.Rd b/man/predict-SDMmodelCV-method.Rd index 6aff044a..4ee1501f 100644 --- a/man/predict-SDMmodelCV-method.Rd +++ b/man/predict-SDMmodelCV-method.Rd @@ -84,8 +84,7 @@ trees defined to train the model and the "response" output type. } } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -122,10 +121,10 @@ predict(model, # Make cloglog prediction for the whole study area, get the average, standard # deviation, and maximum values of the k models, and save the output in three -# files -\dontrun{ +# files. # The following commands save the output in the working directory. Note that -# the filename must include the extension +# the `filename` must include the extension +\dontrun{ maps <- predict(model, data = predictors, fun = c("mean", "sd", "max"), @@ -144,9 +143,7 @@ predict(model, data = predictors, fun = "sd", type = "logistic", - filename = "my_map.tif") -} -} + filename = "my_map.tif")}} } \references{ Wilson P.D., (2009). Guidelines for computing MaxEnt model output diff --git a/man/randomSearch.Rd b/man/randomSearch.Rd index 1f61eea2..cc12a24c 100644 --- a/man/randomSearch.Rd +++ b/man/randomSearch.Rd @@ -57,8 +57,7 @@ An interactive chart showing in real-time the steps performed by the algorithm is displayed in the Viewer pane. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -103,8 +102,7 @@ output@results output@models # Order results by highest test AUC -output@results[order(-output@results$test_AUC), ] -} +output@results[order(-output@results$test_AUC), ]} } \author{ Sergio Vignali diff --git a/man/reduceVar.Rd b/man/reduceVar.Rd index a3275b1c..fa9d2d81 100644 --- a/man/reduceVar.Rd +++ b/man/reduceVar.Rd @@ -61,8 +61,7 @@ An interactive chart showing in real-time the steps performed by the algorithm is displayed in the Viewer pane. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -128,9 +127,7 @@ output <- reduceVar(model, th = 2, metric = "auc", test = test, - use_pc = TRUE) -} -} + use_pc = TRUE)}} } \author{ Sergio Vignali diff --git a/man/swd2csv.Rd b/man/swd2csv.Rd index 2ab2e469..a2c3b678 100644 --- a/man/swd2csv.Rd +++ b/man/swd2csv.Rd @@ -27,8 +27,7 @@ locations. } } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -53,9 +52,7 @@ swd2csv(data, # Save the SWD object in two separate csv files swd2csv(data, - file_name = c("presence.csv", "absence.csv")) -} -} + file_name = c("presence.csv", "absence.csv"))}} } \author{ Sergio Vignali diff --git a/man/thinData.Rd b/man/thinData.Rd index 4068ba4a..e643fb57 100644 --- a/man/thinData.Rd +++ b/man/thinData.Rd @@ -40,8 +40,7 @@ specified using the arguments \code{x} and \code{y}. } } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -94,8 +93,7 @@ thinned_bg <- thinData(data, env = predictors, x = "X", y = "Y") -head(data) -} +head(data)} } \author{ Sergio Vignali diff --git a/man/train.Rd b/man/train.Rd index 9d23ed4f..337b7f2e 100644 --- a/man/train.Rd +++ b/man/train.Rd @@ -91,8 +91,7 @@ named list of model object, with the name corresponding to the used method, see examples. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -187,8 +186,7 @@ model <- train(method = "Maxnet", data = data, fc = "l", reg = 0.8, - folds = spatial_folds) -} + folds = spatial_folds)} ## Train presence absence models # Prepare presence and absence locations @@ -231,8 +229,7 @@ output <- train(method = c("ANN", "BRT", "RF"), ntree = 300, n.trees = 300, shrinkage = 0.001) -output -} +output} } \references{ Venables, W. N. & Ripley, B. D. (2002) Modern Applied Statistics with S. diff --git a/man/tss.Rd b/man/tss.Rd index 5eea30cd..4fa84bda 100644 --- a/man/tss.Rd +++ b/man/tss.Rd @@ -65,10 +65,9 @@ tss(model) tss(model, test = test) -\donttest{ -# Same example but using cross validation instead of training and testing -# datasets -# Create 4 random folds splitting only the presence locations +\donttest{# Same example but using cross validation instead of training and +# testing datasets. Create 4 random folds splitting only the presence +# locations folds = randomFolds(train, k = 4, only_presence = TRUE) @@ -87,8 +86,7 @@ tss(model, # Compute the TSS for the held apart testing dataset tss(model, - test = test) -} + test = test)} } \references{ Allouche O., Tsoar A., Kadmon R., (2006). Assessing the accuracy of species diff --git a/man/varImp.Rd b/man/varImp.Rd index 309dc510..3d584c8a 100644 --- a/man/varImp.Rd +++ b/man/varImp.Rd @@ -33,8 +33,7 @@ For \linkS4class{SDMmodelCV} objects the function returns the average and the standard deviation of the permutation importances of the single models. } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -84,8 +83,7 @@ model <- train(method = "Maxnet", # Compute variable importance vi <- varImp(model, permut = 5) -vi -} +vi} } \author{ Sergio Vignali diff --git a/man/varSel.Rd b/man/varSel.Rd index f9faed27..d06b1c62 100644 --- a/man/varSel.Rd +++ b/man/varSel.Rd @@ -74,8 +74,7 @@ To find highly correlated variables the following formula is used: \deqn{| coeff | \le cor_th} } \examples{ -\donttest{ -# Acquire environmental variables +\donttest{# Acquire environmental variables files <- list.files(path = file.path(system.file(package = "dismo"), "ex"), pattern = "grd", full.names = TRUE) @@ -156,9 +155,7 @@ vs <- varSel(model, cor_th = 0.7, use_pc = TRUE, env = predictors) -vs -} -} +vs}} } \author{ Sergio Vignali