From 11ecb6e6026d10810280f9b59d468d4bd7502e2a Mon Sep 17 00:00:00 2001 From: Hugo Gruson Date: Sat, 20 Feb 2021 11:49:42 +0100 Subject: [PATCH] Specify default directly in sensmodel arg --- R/sensmodel.R | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/R/sensmodel.R b/R/sensmodel.R index fe43c0a54..52ebafe56 100644 --- a/R/sensmodel.R +++ b/R/sensmodel.R @@ -65,7 +65,7 @@ sensmodel <- function(peaksens, range = c(300, 700), lambdacut = NULL, Bmid = NULL, - oiltype = NULL, beta = TRUE, om = NULL, integrate = TRUE, sensnames = NULL) { + oiltype = NULL, beta = TRUE, om = NULL, integrate = TRUE, sensnames = paste0("lmax", peaksens)) { if (!is.null(lambdacut)) { if (is.null(Bmid) & is.null(oiltype)) stop("Bmid or oiltype must be included when including a lambdacut vector", call. = FALSE) if (length(lambdacut) != length(peaksens)) stop("lambdacut must be same length as peaksens", call. = FALSE) @@ -158,20 +158,13 @@ sensmodel <- function(peaksens, range = c(300, 700), lambdacut = NULL, Bmid = NU sensecurves <- as.data.frame(sensecurves) - if (!is.null(sensnames)) { - if (length(sensnames) != length(sensecurves)) { - message("The length of argument 'sensnames' does not equal the number of curves specified by 'peaksens'. Reverting to default names.") - sensnames <- NULL - } else { - names(sensecurves) <- sensnames - } - } - - if (is.null(sensnames)) { - names(sensecurves) <- paste0("lmax", peaksens) + if (length(sensnames) != length(sensecurves)) { + message("The length of argument 'sensnames' does not equal the number of curves specified by 'peaksens'. Reverting to default names.") + sensnames <- paste0("lmax", peaksens) + } else { + names(sensecurves) <- sensnames } - sensecurves <- cbind(wl, sensecurves) class(sensecurves) <- c("sensmod", "rspec", "data.frame")