Skip to content

Commit

Permalink
Improve read_obsnode()
Browse files Browse the repository at this point in the history
  • Loading branch information
mrustl committed Jun 4, 2024
1 parent 0247a34 commit 62e511f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions R/read_obsnode.R
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ read_obsnode <- function(path, to_longer = TRUE) {
is_conc <- grepl("conc", headers_sel)

if(sum(is_conc) > 0) {
headers_sel[is_conc] <- sprintf("%s%d",
headers_sel[is_conc] <- sprintf("%s_%d",
headers_sel[is_conc],
seq_len(sum(is_conc)))
}
Expand All @@ -66,7 +66,8 @@ read_obsnode <- function(path, to_longer = TRUE) {
if(to_longer) {
dat %>%
tidyr::pivot_longer( - time) %>%
tidyr::separate(col = "name", into = c("node", "variable"), sep = "_")
tidyr::separate(col = "name", into = c("node", "variable"), sep = "_") %>%
dplyr::mutate(node = stringr::str_remove(node, "node") %>% as.integer())
} else {
dat
}
Expand Down

0 comments on commit 62e511f

Please sign in to comment.