Skip to content

Commit

Permalink
Fix character column type #128
Browse files Browse the repository at this point in the history
  • Loading branch information
pvanlaake committed Oct 15, 2024
1 parent 5cb0f6e commit 056a1c8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
9 changes: 5 additions & 4 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: tidync
Title: A Tidy Approach to 'NetCDF' Data Exploration and Extraction
Version: 0.3.0.9002
Version: 0.4.0
Authors@R: c(person("Michael", "Sumner", email = "[email protected]", role = c("aut", "cre")),
person("Simon", "Wotherspoon", role = "ctb"),
person("Tomas", "Remenyi", role = "ctb"),
Expand All @@ -9,7 +9,8 @@ Authors@R: c(person("Michael", "Sumner", email = "[email protected]", role = c(
person("Tim", "Lucas", role = "ctb"),
person("Hadley", "Wickham", role = "ctb"),
person("Adrian", "Odenweller", role = "ctb"),
person("Patrick", "Van Laake", role = "ctb"))
person("Patrick", "Van Laake", role = "ctb"),
person("Fabian", "Bernhard", role = "ctb"))
Description: Tidy tools for 'NetCDF' data sources. Explore the contents of a
'NetCDF' source (file or URL) presented as variables organized by grid with a
database-like interface. The hyper_filter() interactive function translates the
Expand All @@ -31,8 +32,8 @@ Imports:
rlang,
tibble,
tidyr,
CFtime (>= 1.2.0)
RoxygenNote: 7.2.3
CFtime (>= 1.4.0)
RoxygenNote: 7.3.2
Suggests: ggplot2,
knitr,
rmarkdown,
Expand Down
18 changes: 13 additions & 5 deletions R/hyper_tibble.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,20 @@ hyper_tibble.tidync<- function(x, ..., na.rm = TRUE, force = FALSE) {
out <- tibble::as_tibble(lapply(slabs, as.vector))

prod_dims <- 1
dn <- dimnames(slabs[[1]])
nm <- names(dn)
trans <- attr(slabs, "transforms")

for (i in seq_along(nm)) {
out[[nm[i]]] <- rep(dn[[i]], each = prod_dims, length.out = total_prod)
prod_dims <- prod_dims * length(dn[[i]])
for (i in seq_along(trans)) {
nm <- names(trans)[i]
nr <- sum(trans[[i]]$selected)

out[[nm]] <- if ("timestamp" %in% colnames(trans[[i]]))
rep(dplyr::filter(trans[[nm]], .data$selected)[["timestamp"]],
each = prod_dims, length.out = total_prod)
else
rep(dplyr::filter(trans[[nm]], .data$selected)[[nm]],
each = prod_dims, length.out = total_prod)

prod_dims <- prod_dims * nr
}
if (na.rm) out <- dplyr::filter(out, !all_na)
out
Expand Down

0 comments on commit 056a1c8

Please sign in to comment.