Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the defunct na.rm option from plot_GrowthCurve() #214

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions NEWS.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ would produce `Inf` (#203, fixed in #206).
(#210, fixed in #211).

### `plot_GrowthCurve()`
* The function now calculates the relative saturation (`n/N`) using the ration of the two integrates.
The values is part of the output table.
* The function now calculates the relative saturation (`n/N`) using the ratio
of the two integrates. The value is part of the output table.
* Argument `na.rm` has been removed: as of version 0.9.23, it was defunct
and only accepted `TRUE` as valid value and produced an error otherwise,
so there is no effective change in behaviour (#137, fixed in #214).

### `plot_KDE()`
* It now officially supports numeric vectors and single-column data frames,
Expand Down
35 changes: 11 additions & 24 deletions R/plot_GrowthCurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@
#' column name if used. For exponential fits at least three dose points
#' (including the natural) should be provided.
#'
#' @param na.rm [logical] (*with default*): excludes `NA` values from the data set prior to any further operations. This argument is defunct and will be removed in a future version!
#'
#' @param mode [character] (*with default*):
#' selects calculation mode of the function.
#' - `"interpolation"` (default) calculates the De by interpolation,
Expand Down Expand Up @@ -304,7 +302,6 @@
#' @export
plot_GrowthCurve <- function(
sample,
na.rm = TRUE,
mode = "interpolation",
fit.method = "EXP",
fit.force_through_origin = FALSE,
Expand Down Expand Up @@ -368,29 +365,19 @@ plot_GrowthCurve <- function(
return(NULL)
}

## optionally, count and exclude NA values and print result
if(na.rm[1]) {
## write warning
if(sum(!complete.cases(sample)) > 0)
warning(paste("[plot_GrowthCurve()]",
sum(!complete.cases(sample)),
"NA value(s) excluded."),
call. = FALSE)

## exclude NA
sample <- na.exclude(sample)

##Check if anything is left after removal
if(nrow(sample) == 0){
message("[plot_GrowthCurve()] Error: After NA removal, nothing is left ",
"from the data set, NULL returned")
return(NULL)
}
## count and exclude NA values and print result
if (sum(!complete.cases(sample)) > 0)
.throw_warning(sum(!complete.cases(sample)),
" NA values removed")

}else{
stop("[plot_GrowthCurve()] Sorry, the argument 'na.rm' is defunct and will be removed in future!",
call. = FALSE)
## exclude NA
sample <- na.exclude(sample)

## Check if anything is left after removal
if (nrow(sample) == 0) {
message("[plot_GrowthCurve()] Error: After NA removal, nothing is left ",
"from the data set, NULL returned")
return(NULL)
}

##3. verbose mode
Expand Down
3 changes: 0 additions & 3 deletions man/plot_GrowthCurve.Rd

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

6 changes: 1 addition & 5 deletions tests/testthat/test_plot_GrowthCurve.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,6 @@ test_that("plot_GrowthCurve", {
"RLum.Results")
})

## test defunct
expect_error(
object = plot_GrowthCurve(LxTxData[,1:2], output.plot = FALSE, na.rm = FALSE))

## do not include reg point
expect_s4_class(
object = plot_GrowthCurve(
Expand Down Expand Up @@ -523,7 +519,7 @@ temp_LambertW <-
verbose = TRUE),
"fit.method set to 'LIN'"))
})
expect_match(warnings, "1 NA value(s) excluded",
expect_match(warnings, "1 NA values removed",
all = FALSE, fixed = TRUE)
expect_match(warnings, "Fitting using an exponential term requires",
all = FALSE, fixed = TRUE)
Expand Down