Skip to content

Commit

Permalink
fixes error when all values of a specific year/sensor are NA
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanbeaudette committed Feb 6, 2025
1 parent 5b9c399 commit aebbbc1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions R/fetchSCAN.R
Original file line number Diff line number Diff line change
Expand Up @@ -349,10 +349,16 @@ fetchSCAN <- function(site.code = NULL, year = NULL, report = 'SCAN', timeseries
.so <- formatC(meta$dataTimeZone * 100, 4, flag = 0)

# create datetime stamp standardized to user-specified timezone
res$datetime <- as.POSIXct(paste(res$Date, res$Time, .so),
format = "%Y-%m-%d %H:%M %z",
tz = tz)
# only if there are >1 records of data
if (nrow(res) > 0) {
res$datetime <- as.POSIXct(
paste(res$Date, res$Time, .so),
format = "%Y-%m-%d %H:%M %z",
tz = tz
)
}

# this will be a 0-row data.frame if all data are NA
return(res)
}

Expand Down

0 comments on commit aebbbc1

Please sign in to comment.