Skip to content

wavenumbers subscript out of bounds error #23

@davidbenncsiro

Description

@davidbenncsiro

I have a file that yields a wavenumbers subscript out of bounds error:

opusreader::opus_read(path)
# Error in wavenumbers[[i]] : subscript out of bounds
# [1] "Error in wavenumbers[[i]] : subscript out of bounds\n"
# attr(,"class")
# [1] "try-error"
# attr(,"condition")
# <simpleError in wavenumbers[[i]]: subscript out of bounds>

I debugged the code and found that it failed here:

https://github.com/pierreroudier/opusreader/blob/main/R/opus_read_raw.R#L851

The code is:

  spc_m <- setNames(
    lapply(
      seq_along(spc_m),
      function(i) {
        colnames(spc_m[[i]]) <- round(wavenumbers[[i]], 1)
        rownames(spc_m[[i]]) <- unique_id
        spc_m[[i]]
      }
    ),
    names(spc_m)
  )

seq_along(spc_m) yields a sequence from 1 to 7. In this particular case, wavenumbers[[6]] has data, but wavenumbers[[7]] does not exist.

I'm talking with my CSIRO collaborators re: whether I can make the file in question available to you for testing. It's just one file out of almost 1000 and this is the only one that fails. So, whether it's a problem with the code or the file is another question, but it appears to have the right length.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions