Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
sgvignali committed Jun 22, 2023
1 parent 6f3bae5 commit 1d26c40
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 15 deletions.
38 changes: 30 additions & 8 deletions R/plotResponse.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,17 @@
#' marginal curves.
#' @param rug logical. If `TRUE` it adds the rug plot for the presence and
#' absence/background locations, available only for continuous variables.
#' @param color The colour of the curve, default is "red".
#'
#' @details Note that fun is not a character argument, you must use `mean` and
#' not `"mean"`.
#' @param color The color of the curve, default is "red".
#'
#' @details
#' * Note that `fun` is not a character argument, you must use `mean` and not
#' `"mean"`.
#' * If you want to modify the plot, first you have to assign the output of the
#' function to a variable, and then you have two options:
#' + Modify the `ggplot` object by editing the theme or adding additional
#' elements
#' + Get the data with `ggplot2::ggplot_build()` and then build your own
#' plot (see examples)
#'
#' @return A \link[ggplot2]{ggplot} object.
#' @export
Expand All @@ -26,8 +33,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 @@ -77,6 +83,23 @@
#' type = "logistic",
#' color = "green")
#'
#' # Modify plot
#' # Change y axes limits
#' my_plot <- plotResponse(model,
#' var = "bio1",
#' type = "cloglog")
#' my_plot +
#' ggplot2::scale_y_continuous(limits = c(0, 1))
#'
#' # Get the data and create your own plot:
#' df <- ggplot2::ggplot_build(my_plot)$data[[1]]
#' plot(df$x, df$y,
#' type = "l",
#' lwd = 3,
#' col = "blue",
#' xlab = "bio1",
#' ylab = "cloglog output")
#'
#' # Train a model with cross validation
#' folds <- randomFolds(data,
#' k = 4,
Expand All @@ -97,8 +120,7 @@
#' plotResponse(model,
#' var = "biome",
#' type = "logistic",
#' color = "green")
#' }
#' color = "green")}
plotResponse <- function(model,
var,
type = NULL,
Expand Down
39 changes: 32 additions & 7 deletions man/plotResponse.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1d26c40

Please sign in to comment.