Skip to content

Commit

Permalink
CRAN presubmit tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonDedman committed Aug 23, 2023
1 parent 49c9658 commit e1cad03
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 27 deletions.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ importFrom(stats,poisson)
importFrom(stats,ppoints)
importFrom(stats,runif)
importFrom(stats,sd)
importFrom(stats,setNames)
importFrom(stats,var)
importFrom(stringi,stri_split_fixed)
importFrom(tidyselect,last_col)
Expand Down
10 changes: 5 additions & 5 deletions R/gbm.auto.R
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,12 @@
#' For Linux/*buntu systems, in terminal, type: 'sudo apt install libgeos-dev', 'sudo apt install
#' libproj-dev', 'sudo apt install libgdal-dev'.
#'
#' 2. Error in FUN(X[[i]], ...) : only defined on a data frame with all numeric
#' 2. Error in FUN(X\[\[i\]\], ...) : only defined on a data frame with all numeric
#' variables. Check your variable types are correct, e.g. numerics haven't been imported
#' as factors because there's an errant first row of text information before the
#' data. Remove NA rows from the response variable if present: convert blank
#' cells to NA on import with read.csv(x, na.strings = "") then
#' samples2 <- samples1[-which(is.na(samples[,resvar_column_number])),]
#' samples2 <- samples1\[-which(is.na(samples\[,resvar_column_number\])),\]
#'
#' 3. At bf=0.5, if nrows <= 42 gbm.step will crash. Use gbm.bfcheck to determine optimal viable bf
#' size
Expand Down Expand Up @@ -142,7 +142,7 @@
#' samples to run BRT modelling. Run gbm.bfcheck to check recommended minimum BF size. Similarly:
#' glm.fit: fitted probabilities numerically 0 or 1 occurred, and glm.fit: algorithm did not
#' converge. Similarly: Error in if (get(paste0("Gaus_BRT", ".tc", j, ".lr", k, ".bf",
#' l))$self.statistics$correlation[[1]]: argument is of length zero. See also: Error 15.
#' l))$self.statistics$correlation\[\[1\]\]: argument is of length zero. See also: Error 15.
#'
#' 10. Anomalous values can obfuscate clarity in line plots e.g. salinity range 32:35ppm but dataset
#' has errant 0 value: plot axis will be 0:35, and 99.99% of the data will be in the tiny bit at
Expand All @@ -151,7 +151,7 @@
#' 11. Error in plot.new() : figure margins too large: In RStudio, adjust plot frame (usually bottom
#' right) to increase its size. Still fails? Set multiplot=FALSE.
#'
#' 12. Error in dev.print(file = paste0("./", names(samples[i]), "/pred_dev_bin.jpeg"): can only
#' 12. Error in dev.print(file = paste0("./", names(samples\[i\]), "/pred_dev_bin.jpeg"): can only
#' print from a screen device. An earlier failed run (e.g. LR/BF too low) left a plotting device
#' open. Close it with: 'dev.off()'.
#'
Expand All @@ -168,7 +168,7 @@
#' 16. If lineplots of factorial variables include empty columns be sure to remove unused levels
#' with samples %<>% droplevels() before the gbm.auto run
#'
#' 17. Error in seq.default(from = min(x$var.levels[[i.var[i]]]), to = max(x$var.levels[[i.var[i]]])
#' 17. Error in seq.default(from = min(x$var.levels\[\[i.var\[i\]\]\]), to = max(x$var.levels\[\[i.var\[i\]\]\])
#' :'from' must be a finite number. If you logged any expvars with log() and they has zeroes in them
#' , those zeroes became imaginary numbers. Use log1p() instead.
#'
Expand Down
10 changes: 5 additions & 5 deletions R/gbm.map.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
#'
#' @param x Vector of longitudes, from make.grid in mapplots; x. Order by this
#' (descending) SECOND.
#' @param y Vector of latitudes, from make.grid in mapplots; grids[,gridslat].
#' @param y Vector of latitudes, from make.grid in mapplots; grids\[,gridslat\].
#' Order by this (descending) first.
#' @param z Vector of abundances generated by gbm.predict.grids, from make.grid
#' in mapplots; grids[,predabund].
#' in mapplots; grids\[,predabund\].
#' @param byx Longitudinal width of grid cell, from make.grid in mapplots.
#' Autogenerated if left blank.
#' @param byy Latitudinal height of grid cell, from make.grid in mapplots.
Expand All @@ -22,7 +22,7 @@
#' @param mapmain Plot title, has species value appended. Default "Predicted
#' CPUE (numbers per hour): ".
#' @param species Response variable name, from basemap in mapplots;
#' names(samples[i]). Defaults to "Response Variable".
#' names(samples\[i\]). Defaults to "Response Variable".
#' @param heatcolours Vector for abundance colour scale, defaults to the heatcol from
#' legend.grid and draw.grid in mapplots which is c("white", "yellow", "orange"
#' , "red", "brown4").
Expand Down Expand Up @@ -56,13 +56,13 @@
#'
#' @details Errors and their origins:
#'
#' Error in seq.default(xlim[1], xlim[2], by = byx):wrong sign in 'by' argument
#' Error in seq.default(xlim\[1\], xlim\[2\], by = byx):wrong sign in 'by' argument
#' Check that your lat & long columns are the right way around. Ensure grids
#' data are gridded, i.e. they are in a regular pattern of same/similar lines of lat/lon, even if
#' they're missing sections.
#'
#' Suggested parameter values:
#' z = rsbdf[,"Unrepresentativeness"]
#' z = rsbdf\[,"Unrepresentativeness"\]
#'
#' mapmain = "Unrepresentativeness: "
#'
Expand Down
7 changes: 4 additions & 3 deletions R/gbm.mapsf.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#' @importFrom ggspatial layer_spatial
#' @importFrom lubridate today
#' @importFrom stars geom_stars st_as_stars
#' @importFrom stats setNames
#' @importFrom sf st_set_crs st_bbox st_transform st_as_sfc st_as_sf st_buffer
#' @importFrom starsExtra trim2
#' @importFrom viridis scale_fill_viridis
Expand Down Expand Up @@ -101,13 +102,13 @@
#'
#' @details
#'
#' Error in seq.default(xlim[1], xlim[2], by = byx):wrong sign in 'by' argument
#' Error in seq.default(xlim\[1\], xlim\[2\], by = byx):wrong sign in 'by' argument
#' Check that your lat & long columns are the right way around. Ensure grids (predabund) data are
#' gridded, i.e. they are in a regular pattern of same/similar lines of lat/lon, even if they're
#' missing sections.
#'
#' Suggested parameter values:
#' z = rsbdf[,"Unrepresentativeness"]
#' z = rsbdf\[,"Unrepresentativeness"\]
#'
#' mapmain = "Unrepresentativeness: "
#'
Expand Down Expand Up @@ -261,7 +262,7 @@ gbm.mapsf <- function(
if (!inherits(map, "ggmap")) stop("map must be a ggmap object")
# Extract the bounding box (in lat/lon) from the ggmap to a numeric vector,
# and set the names to what sf::st_bbox expects:
map_bbox <- setNames(unlist(attr(map, "bb")), c("ymin", "xmin", "ymax", "xmax"))
map_bbox <- stats::setNames(unlist(attr(map, "bb")), c("ymin", "xmin", "ymax", "xmax"))
# Convert the bbox to an sf polygon, transform it to 3857,
# and convert back to a bbox (convoluted, but it works)
bbox_3857 <- sf::st_bbox(sf::st_transform(sf::st_as_sfc(sf::st_bbox(map_bbox, crs = 4326)), 3857))
Expand Down
10 changes: 8 additions & 2 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "cran-comments"
author: "Simon Dedman"
date: "25 May 2023"
date: "23 August 2023"
output: html_document
---

Expand All @@ -19,10 +19,16 @@ knitr::opts_chunk$set(echo = TRUE)

## R CMD check results

0 errors | 0 warnings | 1 note
0 errors | 1 warnings | 2 notes

Warnings:

* "Rd files with duplicated alias 'gbm.auto': ‘gbm.auto-package.Rd’ ‘gbm.auto.Rd’". Have found no way to remove this, caused by lifecycle and usethis autogeneration of gbm.auto-package.R and Rd.

Notes:

* Possible code problems: no visible binding for global variables: named variables are column names in a csv exported by another function.

* Non-standard things, png file created by examples, doesn't exist permanently.

***
Expand Down
10 changes: 5 additions & 5 deletions man/gbm.auto.Rd

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

10 changes: 5 additions & 5 deletions man/gbm.map.Rd

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

4 changes: 2 additions & 2 deletions man/gbm.mapsf.Rd

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

0 comments on commit e1cad03

Please sign in to comment.