Commit 70f6e599 authored by Enrico Schumann's avatar Enrico Schumann

[file_info] Simplify code; return 't.type'

parent 7b4acf5c
2017-11-14 Enrico Schumann <es@enricoschumann.net>
* R/functions.R (file_info): simplify code;
return 't.type'
2017-10-24 Enrico Schumann <es@enricoschumann.net>
* DESCRIPTION (Version): Version: 0.5-0
......
......@@ -314,22 +314,24 @@ file_info <- function(dir, file) {
exists = file.exists(dfile),
columns = character(nf),
nrows = NA,
min_timestamp = -Inf,
max_timestamp = Inf,
t.type = NA,
min.timestamp = NA,
max.timestamp = NA,
stringsAsFactors = FALSE)
for (i in seq_len(nf)) {
if (!res[["exists"]][i])
next
fi <- try(read_ts_tables(dfile[i]), silent = TRUE)
fi <- try(read_ts_tables(dfile[i], return.class = NULL), silent = TRUE)
if (inherits(fi, "try-error"))
next
res[["nrows"]][i] <- length(fi$timestamp)
res[["min_timestamp"]][i] <- suppressWarnings(min(fi$timestamp))
res[["max_timestamp"]][i] <- suppressWarnings(max(fi$timestamp))
if (length(fi$timestamp)) {
res[["min.timestamp"]][i] <- min(fi$timestamp)
res[["max.timestamp"]][i] <- max(fi$timestamp)
res[["t.type"]][i] <- class(fi$timestamp)
}
}
res[["min_timestamp"]][!is.finite(res[["min_timestamp"]])] <- NA
res[["max_timestamp"]][!is.finite(res[["max_timestamp"]])] <- NA
class(res) <- c("file_info", "data.frame")
res
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment