Commit 7e8cac79 authored by Dorchies David's avatar Dorchies David
Browse files

fix: wrong type in reach and section numbers

- fix ids to integers
- add class to result objects

Refs #18
1 merge request!13Resolve "Compact tidy result"
Pipeline #34369 passed with stage
in 3 minutes and 27 seconds
Showing with 12 additions and 1 deletion
+12 -1
......@@ -46,6 +46,13 @@ tidy_result <- function(res) {
l <- lapply(strsplit(x, ":", fixed = TRUE),
function(obj) {
df <- data.frame(x = obj[2])
if (obj[1] != "var") {
if (obj[1] == "t") {
df$x <- as.numeric(df$x)
} else {
df$x <- as.integer(df$x)
}
}
names(df) <- obj[1]
return(df)
})
......@@ -53,7 +60,9 @@ tidy_result <- function(res) {
})
df_obj <- do.call(rbind, l)
df$key <- NULL
cbind(df_obj, df)
df <- cbind(df_obj, df)
class(df) <- c("SicResultTidy", class(df))
df
}
#' @rdname tidy_result
......@@ -71,5 +80,6 @@ compact_tidy_result <- function(res) {
attr(df, "t") <- res[, 1]
df$t <- NULL
df$value <- NULL
class(df) <- c("SicResultCompact", class(df))
df
}
......@@ -25,4 +25,5 @@ test_that("get_result with tidy return a tidy result", {
expect_s3_class(result, "data.frame")
expect_equal(names(result), c("bf", "sn", "var", "values"))
expect_equal(attr(result, "t"), seq(0, 86400, by = 60))
expect_type(result$bf, "integer")
})
Supports Markdown
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