Skip to content

Commit

Permalink
Removing call from function errors
Browse files Browse the repository at this point in the history
  • Loading branch information
rogerssam committed Jun 9, 2024
1 parent d0360cb commit 14e82ff
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion R/autoplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ autoplot.design <- function(object, rotation = 0, size = 4, margin = FALSE, pale
colour_palette <- scales::viridis_pal(option = palette)(ntrt)
}
else {
stop("Invalid value for palette.")
stop("Invalid value for palette.", call. = FALSE)
}

hcl <- farver::decode_colour(colour_palette, "rgb", "hcl")
Expand Down
2 changes: 1 addition & 1 deletion R/create_buffers.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ create_buffers <- function(design, type, blocks = FALSE) {
}
# Match block, blocks, or b
else if(grepl("(^blocks?$|^b$)", tolower(type))) {
stop("Block buffers are not yet supported.")
stop("Block buffers are not yet supported.", call. = FALSE)
}
else {
stop("Invalid buffer option: ", type, call. = FALSE)
Expand Down
8 changes: 4 additions & 4 deletions R/des_info.R
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ des_info <- function(design.obj,

# Check brows and bcols supplied if necessary
if(design.obj$parameters$design == "rcbd" & anyNA(c(brows, bcols))) {
stop("Design has blocks so brows and bcols must be supplied.")
stop("Design has blocks so brows and bcols must be supplied.", call. = FALSE)
}
else if(design.obj$parameters$design == "factorial") {
if(design.obj$parameters$applied == "rcbd" & anyNA(c(brows, bcols))) {
stop("Design has blocks so brows and bcols must be supplied.")
stop("Design has blocks so brows and bcols must be supplied.", call. = FALSE)
}

# If factorial design, and names are supplied, use them
Expand Down Expand Up @@ -160,7 +160,7 @@ des_info <- function(design.obj,
}
else if(design.obj$parameters$design == "split") {
if(design.obj$parameters$applied == "rcbd" & anyNA(c(brows, bcols))) {
stop("Design has blocks so brows and bcols must be supplied.")
stop("Design has blocks so brows and bcols must be supplied.", call. = FALSE)
}

# If names are supplied, use them
Expand Down Expand Up @@ -556,7 +556,7 @@ des_info <- function(design.obj,
# Do nothing
}
else {
stop("save must be one of 'none'/FALSE, 'both'/TRUE, 'plot', or 'workbook'.")
stop("save must be one of 'none'/FALSE, 'both'/TRUE, 'plot', or 'workbook'.", call. = FALSE)
}
}
else if(save) {
Expand Down
20 changes: 10 additions & 10 deletions R/design.R
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,19 @@ design <- function(type,

# Some error checking of inputs before creating design
if(!is.na(brows) & brows > nrows) {
stop("brows must not be larger than nrows")
stop("brows must not be larger than nrows", call. = FALSE)
}

if(!is.na(bcols) & bcols > ncols) {
stop("bcols must not be larger than ncols")
stop("bcols must not be larger than ncols", call. = FALSE)
}

if(!is.numeric(size)) {
stop("size must be numeric")
stop("size must be numeric", call. = FALSE)
}

if((!is.logical(seed) | is.na(seed)) & !is.numeric(seed)) {
stop("seed must be numeric or TRUE/FALSE")
stop("seed must be numeric or TRUE/FALSE", call. = FALSE)
}

dim <- nrows*ncols
Expand Down Expand Up @@ -149,7 +149,7 @@ design <- function(type,

else if(tolower(type) == "split") {
if(is.null(sub_treatments) | anyNA(sub_treatments)) {
stop("sub_treatments are required for a split plot design")
stop("sub_treatments are required for a split plot design", call. = FALSE)
}
trs <- length(treatments)*length(sub_treatments)*reps
outdesign <- agricolae::design.split(trt1 = treatments,
Expand All @@ -163,11 +163,11 @@ design <- function(type,
savename <- gsub(":", "_", savename)

if(type_split[2] %!in% c("crd", "rcbd", "lsd")) {
stop("Crossed designs of type '", type_split[2], "' are not supported")
stop("Crossed designs of type '", type_split[2], "' are not supported", call. = FALSE)
}

if(length(treatments) > 3) {
stop("Crossed designs with more than three treatment factors are not supported")
stop("Crossed designs with more than three treatment factors are not supported", call. = FALSE)
}
trs <- ifelse(tolower(type_split[2])=="lsd", prod(treatments)^2, prod(treatments)*reps)

Expand All @@ -178,15 +178,15 @@ design <- function(type,
}

else {
stop("Designs of type '", type, "' are not supported")
stop("Designs of type '", type, "' are not supported", call. = FALSE)
}

if(dim > trs) {
warning("Area provided is larger than treatments applied. Please check inputs.")
warning("Area provided is larger than treatments applied. Please check inputs.", call. = FALSE)
}

if(dim < trs) {
warning("Area provided is smaller than treatments applied. Please check inputs.")
warning("Area provided is smaller than treatments applied. Please check inputs.", call. = FALSE)
}

output <- des_info(design.obj = outdesign, nrows = nrows, ncols = ncols,
Expand Down
2 changes: 1 addition & 1 deletion R/install_asreml.R
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ create_mac_folder <- function() {
else {
stop("ASReml-R cannot be installed until the folder '/Library/Application Support/Reprise' is created with appropriate permissions.
Please run the following command on your terminal:
sudo -S mkdir '/Library/Application Support/Reprise' && sudo -S chmod 777 '/Library/Application Support/Reprise'")
sudo -S mkdir '/Library/Application Support/Reprise' && sudo -S chmod 777 '/Library/Application Support/Reprise'", call. = FALSE)
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions R/logltest.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
logl_test <- function(model.obj, rand.terms = NULL, resid.terms = NULL, decimals = 3, numeric = FALSE, quiet = FALSE) {

if(!inherits(model.obj, "asreml")){
stop("Only asreml models are supported at this time.")
stop("Only asreml models are supported at this time.", call. = FALSE)
}

if(is.null(rand.terms) & is.null(resid.terms)) {
stop("One of rand.terms or resid.terms must be provided.")
stop("One of rand.terms or resid.terms must be provided.", call. = FALSE)
}

# Find terms on the boundary
Expand Down
8 changes: 4 additions & 4 deletions R/mct.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ multiple_comparisons <- function(model.obj,
reserved_col_names <- c("predicted.value", "std.error", "Df",
"groups", "PredictedValue", "ApproxSE", "ci", "low", "up")
if(any(vars %in% reserved_col_names)) {
stop("Invalid column name. Please change the name of column(s): ", vars[vars %in% reserved_col_names])
stop("Invalid column name. Please change the name of column(s): ", vars[vars %in% reserved_col_names], call. = FALSE)
}

if(inherits(model.obj, "asreml")){
Expand All @@ -157,13 +157,13 @@ multiple_comparisons <- function(model.obj,
}

if(!missing(pred.obj)) {
warning("Argument `pred.obj` has been deprecated and will be removed in a future version. Predictions are now performed internally in the function.")
warning("Argument `pred.obj` has been deprecated and will be removed in a future version. Predictions are now performed internally in the function.", call. = FALSE)
}

pred.obj <- quiet(asreml::predict.asreml(model.obj, classify = classify, sed = TRUE, trace = FALSE, ...))
# Check if all the predicted values are NA. If so, suggests the need of the `present` argument
if(all(is.na(pred.obj$pvals$predicted.value)) & all(is.na(pred.obj$pvals$std.error))) {
stop("All predicted values are aliased. Perhaps you need the `present` argument?")
stop("All predicted values are aliased. Perhaps you need the `present` argument?", call. = FALSE)
}

# Check if any treatments are aliased, and remove them and print a warning
Expand Down Expand Up @@ -282,7 +282,7 @@ multiple_comparisons <- function(model.obj,
}

else {
stop("Models of type ", class(model.obj), " are not supported.")
stop("Models of type ", class(model.obj), " are not supported.", call. = FALSE)
}

# Check that the predicted levels don't contain a dash -, if they do replace and display warning
Expand Down
2 changes: 1 addition & 1 deletion R/resplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ resplot <- function(model.obj, shapiro = TRUE, call = FALSE, label.size = 10, ax
}
}
else {
stop("model.obj must be a linear (mixed) model object. Currently supported model types are: aov, lm, lmerMod, lmerModLmerTest, asreml, mmer or art")
stop("model.obj must be a linear (mixed) model object. Currently supported model types are: aov, lm, lmerMod, lmerModLmerTest, asreml, mmer or art", call. = FALSE)
}

aa <- data.frame(residuals = resids, fitted = fits, lvl = rep(1:facet, k))
Expand Down
6 changes: 3 additions & 3 deletions R/variogram.r
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
variogram <- function(model.obj, row = NA, column = NA, horizontal = TRUE, palette = "default") {

if(!(inherits(model.obj, "asreml"))) {
stop("model.obj must be an asreml model object")
stop("model.obj must be an asreml model object", call. = FALSE)
}

if(attr(model.obj$formulae$residual,"term.labels") == "units") {
stop("Residual term must include spatial component.")
stop("Residual term must include spatial component.", call. = FALSE)
}

vario_points <- vario_df(model.obj, row, column)
Expand Down Expand Up @@ -146,7 +146,7 @@ variogram <- function(model.obj, row = NA, column = NA, horizontal = TRUE, palet
col.regions = scales::brewer_pal(palette = palette)(11))
}
else {
stop("Invalid value for palette.")
stop("Invalid value for palette.", call. = FALSE)
}
output[[i]] <- cowplot::plot_grid(b, a, nrow = 2, scale = c(2, 1))
if(!orig_row) {
Expand Down

0 comments on commit 14e82ff

Please sign in to comment.