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

error in fit_SurfaceExposure() if data contains NAs #162

Closed
mcol opened this issue Aug 21, 2024 · 0 comments
Closed

error in fit_SurfaceExposure() if data contains NAs #162

mcol opened this issue Aug 21, 2024 · 0 comments
Assignees
Labels
bug (potentially) Is seems like a bug, but it's unclear what real effect it may have

Comments

@mcol
Copy link
Contributor

mcol commented Aug 21, 2024

The following generates unexpected warnings:

data("ExampleData.SurfaceExposure", envir = environment())
fit_SurfaceExposure(rbind(ExampleData.SurfaceExposure$sample_1, NA))

# Warning messages:
# 1: NA values in 'data' were removed. 
# 2: In plot_settings$x[, 2] - error :
#   longer object length is not a multiple of shorter object length
# 3: In plot_settings$x[, 2] + error :
#   longer object length is not a multiple of shorter object length

Warning 1 is fine as we raise it when we remove the NAs. However the other two are signalling a bug. Indeed, the following is incorrect:

# extract errors into seperate variable
if (ncol(data) >= 3 && !global_fit)
error <- data[ ,3]
else
error <- NULL
## Take only the first to columns (depth, signal)
if (ncol(data) > 2 && !global_fit)
data <- data[ ,1:2]
## remove rows with NA
if (any(is.na(data))) {
data <- data[complete.cases(data), ]
if (settings$verbose)
warning("NA values in 'data' were removed.", call. = FALSE)
}

What happens, is that we first save column 3 of our data into the error variable, then a few lines below, we remove all NAs. At this point error has length 102, but data has length 101, and the additional warnings are thrown here because of this mismatch.

@mcol mcol added the bug (potentially) Is seems like a bug, but it's unclear what real effect it may have label Aug 21, 2024
@mcol mcol added this to the v0.9.25 (autumn CRAN release) milestone Aug 21, 2024
@mcol mcol self-assigned this Aug 21, 2024
@RLumSK RLumSK closed this as completed Aug 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug (potentially) Is seems like a bug, but it's unclear what real effect it may have
Projects
None yet
Development

No branches or pull requests

2 participants