Skip to content

Commit

Permalink
[dims] further cleanup and update roxygen
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Jun 29, 2024
1 parent 7c94ede commit 2bfb12b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Suggests:
VignetteBuilder:
knitr
Encoding: UTF-8
RoxygenNote: 7.3.1
RoxygenNote: 7.3.2
Roxygen: list(markdown = TRUE)
Config/testthat/edition: 3
Config/testthat/parallel: true
24 changes: 16 additions & 8 deletions R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -1238,17 +1238,25 @@ is_dims <- function(x) {
}

#' check if non consecutive dims is equal sized: "A1:A4,B1:B4"
get_dims <- function(dims, check = TRUE, cols = TRUE) {
#' @param dims dims
#' @param check check if all the same size
#' @param cols return columns index
#' @keywords internal
#' @noRd
get_dims <- function(dims, check = FALSE, cols = FALSE, rows = FALSE) {

rows <- unique(
lapply(dims, FUN = function(dim) {
dimensions <- strsplit(dim, ":")[[1]]
as.integer(gsub("[[:upper:]]", "", dimensions))
})
)
if (check || rows) {
rows <- unique(
lapply(dims, FUN = function(dim) {
dimensions <- strsplit(dim, ":")[[1]]
as.integer(gsub("[[:upper:]]", "", dimensions))
})
)
}

if (check)
if (check) {
return(length(rows) == 1)
}

if (cols) {
cols <- unique(
Expand Down
6 changes: 3 additions & 3 deletions R/wb_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ dims_to_dataframe <- function(dims, fill = FALSE, empty_rm = FALSE) {
# condition 1) contains dims separator, but all dims are of
# equal size: "A1:A5,B1:B5"
# condition 2) either "A1:B5" or separator, but unequal size or "A1:A2,A4:A6,B1:B5"
if (has_dim_sep && get_dims(dims)) {
if (has_dim_sep && get_dims(dims, check = TRUE)) {

full_rows <- get_dims(dims, check = FALSE, cols = FALSE)
full_cols <- sort(get_dims(dims, check = FALSE, cols = TRUE))
full_rows <- get_dims(dims, rows = TRUE)
full_cols <- sort(get_dims(dims, cols = TRUE))

rows_out <- unlist(full_rows)
cols_out <- int2col(full_cols)
Expand Down
3 changes: 2 additions & 1 deletion man/convert_date.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2bfb12b

Please sign in to comment.