Skip to content

Commit

Permalink
for a short file, metalong could have just one row, which was being c…
Browse files Browse the repository at this point in the history
…oerced to vector

We are less likely to see this with metashort, but adding the same logic just in case
  • Loading branch information
l-k- committed Dec 21, 2023
1 parent 354fff2 commit 2fa018d
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions R/g.getmeta.R
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,14 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
if (filecorrupt == FALSE & filetooshort == FALSE & filedoesnotholdday == FALSE) {
cut = count:nrow(metashort)
if (length(cut) > 1) {
metashort = as.matrix(metashort[-cut,])
tmp = metashort[-cut,]
# for a very small file, there could be just one row in metashort[-cut,], so it gets coerced to a vector.
# But what we actually need is a 1-row matrix. So we need to transpose it.
if(is.vector(tmp)) {
metashort = as.matrix(t(tmp))
} else {
metashort = as.matrix(tmp)
}
}
if (nrow(metashort) > 1) {
starttime3 = round(as.numeric(starttime)) #numeric time but relative to the desiredtz
Expand All @@ -737,9 +744,16 @@ g.getmeta = function(datafile, params_metrics = c(), params_rawdata = c(),
time6 = strftime(time6, format = "%Y-%m-%dT%H:%M:%S%z")
metashort[,1] = as.character(time6)
}
cut2 = (count2):nrow(metalong) # how it was
cut2 = count2:nrow(metalong)
if (length(cut2) > 1) {
metalong = as.matrix(metalong[-cut2,])
tmp = metalong[-cut2,]
# for a very small file, there could be just one row in metalong[-cut2,], so it gets coerced to a vector.
# But what we actually need is a 1-row matrix. So we need to transpose it.
if(is.vector(tmp)) {
metalong = as.matrix(t(tmp))
} else {
metalong = as.matrix(tmp)
}
}
if (nrow(metalong) > 2) {
starttime4 = round(as.numeric(starttime)) #numeric time but relative to the desiredtz
Expand Down

0 comments on commit 2fa018d

Please sign in to comment.