Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
r-a-dobson committed Jun 28, 2024
1 parent 95a5c1a commit a2e4a37
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 17 deletions.
17 changes: 2 additions & 15 deletions R/brt_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -77,27 +77,22 @@
#' @examples
#'
#'data("sample_explan_data")
#'
#'sample_explan_data$weights<-1-sample_explan_data$REL_SAMP_EFFORT
#'
#'\dontshow{
#'sample_filt_data<-sample_explan_data[1:100,]
#'sample_filt_data<-sample_explan_data[1:65,]
#'}
#'
#'
#'split <- sample(c(TRUE, FALSE),
#' replace=TRUE,
#' nrow(sample_explan_data),
#' prob = c(0.75, 0.25))
#'
#'training <- sample_explan_data[split, ]
#'testing <- sample_explan_data[!split, ]
#'
#'brt_fit(
#' occ.data = training,
#' test.data = testing,
#' response.col = "presence.absence",
#' distribution = "bernoulli",
#' weights.col = "weights",
#' varnames = colnames(training)[14:16],
#' interaction.depth = 2
#')
Expand Down Expand Up @@ -158,14 +153,6 @@ brt_fit <- function(occ.data,
# Create formula using response and explanatory variables specified
formula <- stats::formula(paste(response.col, paste(varnames, collapse = " + "), sep = " ~ "))

# Set response variable as correct class for "bernoulli" distribution
if (distribution == "bernoulli") {
if (!is.character(occ.data[, response.col])) {
occ.data[, response.col] <- as.character(occ.data[, response.col])
}
}


# Remove rows that contain NA where applicable.
occ.data <- occ.data[!is.na(occ.data[, response.col]), ]
for (v in 1:length(varnames)) {
Expand Down
4 changes: 2 additions & 2 deletions R/spatiotemp_bias.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ spatiotemp_bias <- function(occ.data,

# Plot histogram of frequency of records for each day to visualise bias
p<- ggplot2::ggplot(occ.data,
ggplot2::aes_string(x = as.numeric(as.vector((occ.data[, temp])))))+
ggplot2::geom_histogram(binwidth = 1,
ggplot2::aes_string(x = occ.data[[temp]]))+
ggplot2::geom_histogram(
color = "black",
fill = "white")+
ggplot2::labs(title = paste0("Frequency distribution of records: ", temp),
Expand Down

0 comments on commit a2e4a37

Please sign in to comment.