Skip to content

readAxivity()` fails with "object 'prevStart' not found" when only the final block is requested #98

Description

@j262byuu

readAxivity(start = n - 1, end = n), where n is the number of data blocks, fails with:

object 'prevStart' not found

That range asks for exactly one block, the final one. Any range starting earlier works, including a full read.

Reproducible example

library(GGIRread)

f <- system.file("testfiles/ax3_testfile.cwa", package = "GGIRread")
n <- (file.info(f)$size - 1024) / 512    # 145 data blocks

readAxivity(f, start = n - 3, end = n, progressBar = FALSE)   # ok, 362 rows
readAxivity(f, start = n - 1, end = n, progressBar = FALSE)   # Error: object 'prevStart' not found

Same on ax6_testfile.cwa, 283 blocks, start = 282, end = 283.

R 4.5.2, Windows.

Cause

Previously there's a check to prevent this, open 0522630 then search the following:

if (prevRaw$start >= start & pos <= nr & exists("prevStart") & exists("prevLength")) {

The later refactor removed this part

Why it may matter

If chunked processing leaves exactly one block in the final chunk, GGIRread will fail

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions