Skip to content

Commit

Permalink
Remove empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
sgvignali committed Jun 22, 2023
1 parent 1d26c40 commit 15a151b
Show file tree
Hide file tree
Showing 46 changed files with 116 additions and 222 deletions.
10 changes: 4 additions & 6 deletions R/SDMmodel2MaxEnt.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"))
Expand Down
5 changes: 1 addition & 4 deletions R/auc.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -86,8 +84,7 @@
#'
#' # Compute the AUC for the held apart testing dataset
#' auc(model,
#' test = test)
#' }
#' test = test)}
auc <- function(model,
test = NULL) {

Expand Down
6 changes: 2 additions & 4 deletions R/doJk.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -94,8 +93,7 @@
#'
#' jk$results
#' jk$models_without
#' jk$models_withonly
#' }
#' jk$models_withonly}
doJk <- function(model,
metric,
variables = NULL,
Expand Down
6 changes: 2 additions & 4 deletions R/gridSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -89,8 +88,7 @@
#' metric = "aicc",
#' env = predictors,
#' save_models = FALSE)
#' output@results
#' }
#' output@results}
gridSearch <- function(model,
hypers,
metric,
Expand Down
6 changes: 2 additions & 4 deletions R/maxentTh.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -36,8 +35,7 @@
#' data = data,
#' fc = "l")
#'
#' maxentTh(model)
#' }
#' maxentTh(model)}
maxentTh <- function(model) {

if (!inherits(model@model, "Maxent"))
Expand Down
6 changes: 2 additions & 4 deletions R/maxentVarImp.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -44,8 +43,7 @@
#' data = data,
#' fc = "l")
#'
#' maxentVarImp(model)
#' }
#' maxentVarImp(model)}
maxentVarImp <- function(model) {

if (.get_model_class(model) != "Maxent")
Expand Down
10 changes: 4 additions & 6 deletions R/modelReport.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -71,9 +71,7 @@
#' only_presence = TRUE,
#' jk = TRUE,
#' env = predictors,
#' permut = 2)
#' }
#' }
#' permut = 2)}}
modelReport <- function(model,
folder,
test = NULL,
Expand Down
7 changes: 2 additions & 5 deletions R/optimizeModel.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions R/plotCor.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions R/plotJk.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down
16 changes: 6 additions & 10 deletions R/plotPA.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
#'
Expand All @@ -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,
Expand Down
10 changes: 4 additions & 6 deletions R/plotPred.R
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,17 @@
#' @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")
#'
#' # Custom colors
#' plotPred(map,
#' lt = "Habitat suitability",
#' colorramp = c("#2c7bb6", "#ffffbf", "#d7191c"))
#' }
#' colorramp = c("#2c7bb6", "#ffffbf", "#d7191c"))}
plotPred <- function(map,
lt = "",
colorramp = NULL,
Expand Down
4 changes: 2 additions & 2 deletions R/plotROC.R
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -47,8 +49,6 @@
#' # Plot the training and testing ROC curves
#' plotROC(model,
#' test = test)
#'
#' @author Sergio Vignali
plotROC <- function(model,
test = NULL) {

Expand Down
3 changes: 1 addition & 2 deletions R/predict-SDMmodel.R
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
13 changes: 5 additions & 8 deletions R/predict-SDMmodelCV.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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"),
Expand All @@ -119,9 +118,7 @@
#' data = predictors,
#' fun = "sd",
#' type = "logistic",
#' filename = "my_map.tif")
#' }
#' }
#' filename = "my_map.tif")}}
setMethod(
f = "predict",
signature = "SDMmodelCV",
Expand Down
6 changes: 2 additions & 4 deletions R/randomSearch.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down
7 changes: 2 additions & 5 deletions R/reduceVar.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -101,9 +100,7 @@
#' th = 2,
#' metric = "auc",
#' test = test,
#' use_pc = TRUE)
#' }
#' }
#' use_pc = TRUE)}}
reduceVar <- function(model,
th,
metric,
Expand Down
7 changes: 2 additions & 5 deletions R/swd2csv.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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) {

Expand Down
Loading

0 comments on commit 15a151b

Please sign in to comment.