wadpac / GGIR

Code corresponding to R package GGIR
https://wadpac.github.io/GGIR/
Apache License 2.0
99 stars 62 forks source link

Minor bug appending S object when imputing data in actigraph files #1109

Closed jhmigueles closed 6 months ago

jhmigueles commented 6 months ago

Appending of the S object (i.e., leftover data from previous chunk) when reading the file is problematic when there are remaining epochs to be imputed in the current chunk, yet there were not remaining epochs in the previous chunk (i.e., in S).

Lines 242:249 of g.getmeta are in charge of appending the data:

if (params_rawdata[["imputeTimegaps"]]) {
          if ("remaining_epochs" %in% colnames(data)) {
            if (ncol(S) == (ncol(data) - 1)) {
              # this block has time gaps while the previous block did not
              S = cbind(S, 1)
              colnames(S)[4] = "remaining_epochs"
            }
          } 

The line colnames(S)[4] = "remaining_epochs" would change the column name z for remaining_epochs in the case that time is available in the file. Columns would be time (1), x (2), y (3), z(4)... Instead, I propose changing that line to colnames(S)[ncol(s)] = "remaining_epochs" so that it adapts to the number of columns.

vincentvanhees commented 6 months ago

This was fixed in https://github.com/wadpac/GGIR/pull/1106