Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Review wb_dims() #702

Merged
merged 46 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
e67a01e
Fix `assert_class()` in case not able to parse `sx`.
olivroy Jul 19, 2023
bc4c66e
WIP `wb_dims()`
olivroy Jul 19, 2023
617a9c8
Add more failing tests for cols with names.
olivroy Jul 19, 2023
dbd7a77
Add arguments to assert_class to make sure failures are correctly rep…
olivroy Jul 19, 2023
3bcc3dd
Remove some partial matchings.
olivroy Jul 19, 2023
02a18c6
Rewrite `wb_dims()` and add more tests
olivroy Jul 19, 2023
6e3533f
Lint + tweak test.
olivroy Jul 19, 2023
cafd5ab
Merged upstream/main into wb_dims_improve
olivroy Jul 20, 2023
d8137a1
Put `match.arg_wrapper()` before `wb_dims()`
olivroy Jul 20, 2023
453fd11
Update vignettes to pass R CMD CHECK on CI
olivroy Jul 20, 2023
69d59c6
Remove `allow_null` argument.
olivroy Jul 20, 2023
8be9dd8
Fix warnings in examples.
olivroy Jul 20, 2023
491a026
Progress before changing a behaviour
olivroy Jul 20, 2023
4f2021f
other behaviour change
olivroy Jul 20, 2023
d3fdf93
Progress
olivroy Jul 20, 2023
9408e78
Progress
olivroy Jul 20, 2023
54d1a88
Comment out annoying messages.
olivroy Jul 20, 2023
8689e63
Tweaks + vignettes update (to reflect latest API)
olivroy Jul 20, 2023
9dc7937
Fix tests, and lint
olivroy Jul 20, 2023
bb50835
actually fix lint + tests
olivroy Jul 20, 2023
2ec24f3
Merge branch 'main' into wb_dims_improve
olivroy Jul 20, 2023
1580f43
Fix for providing both cols and rows with `x`
olivroy Jul 21, 2023
5df2d47
Tests passing (if we exclude row names)
olivroy Jul 21, 2023
41250d3
Clean-up what currently works vs not work
olivroy Jul 21, 2023
6d20eaa
Skip these tests for now.
olivroy Jul 21, 2023
2874c6a
Wrap long lines + fix R code formatting
olivroy Jul 22, 2023
21e5118
Merged upstream/main into wb_dims_improve
olivroy Jul 22, 2023
b622894
style / indent
olivroy Jul 22, 2023
3e6126e
Change srow -> frow, scol -> fcol
olivroy Jul 22, 2023
4240914
Put rows/arg reading all at the same place. Adjust test.
olivroy Jul 22, 2023
b0ab288
more cleanup
olivroy Jul 22, 2023
f3eedda
Tweak example
olivroy Jul 22, 2023
f40aa7e
Rm warning example
olivroy Jul 22, 2023
c1711c0
Implement new approach with a new `select` argument.
olivroy Jul 24, 2023
2a7412f
Merge branch 'main' into wb_dims_improve
olivroy Jul 24, 2023
719925d
Cleanup
olivroy Jul 24, 2023
2f5d11e
Cleanup
olivroy Jul 24, 2023
795a855
Merged upstream/main into wb_dims_improve
olivroy Jul 24, 2023
56f36f3
Tweak docs
olivroy Jul 24, 2023
51ed6c5
Address comments!
olivroy Jul 25, 2023
b50493c
Error on the empty case. Enforce consecutive input!
olivroy Jul 25, 2023
c159733
Update R/utils.R
olivroy Jul 25, 2023
6fbbe58
Update man/wb_dims.Rd
olivroy Jul 25, 2023
7afc8b8
Update converters.R
JanMarvin Jul 25, 2023
87a0148
Update utils.R
JanMarvin Jul 25, 2023
84522c6
Update converters.R
JanMarvin Jul 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions R/asserts.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

assert_class <- function(x, class, or_null = FALSE, all = FALSE, package = NULL, envir = parent.frame()) {
# Use arg_nm to override the default
olivroy marked this conversation as resolved.
Show resolved Hide resolved
assert_class <- function(x, class, or_null = FALSE, all = FALSE, package = NULL, envir = parent.frame(), arg_nm = NULL) {
sx <- as.character(substitute(x, envir))
if (identical(sx, character(0)) || !is.null(arg_nm)) {
olivroy marked this conversation as resolved.
Show resolved Hide resolved
sx <- arg_nm %||% "argument"
}

ok <- if (all) {
all(vapply(class, function(i) inherits(x, i), NA))
Expand Down
7 changes: 3 additions & 4 deletions R/class-workbook-wrappers.R
Original file line number Diff line number Diff line change
Expand Up @@ -1710,8 +1710,8 @@ wb_set_order <- function(wb, sheets) {
#' sheet = 1,
#' name = "iris",
#' dims = wb_dims(
#' row = seq_len(nrow(iris) + 1),
#' col = seq_along(iris)
#' rows = seq_len(nrow(iris) + 1),
#' cols = seq_along(iris)
#' )
#' )
#'
Expand Down Expand Up @@ -1903,8 +1903,7 @@ wb_remove_filter <- function(wb, sheet = current_sheet()) {
#' "t" = as.POSIXct("2016-01-01") + -5:5 * 10000
#' )
#' wb$add_data_table(2, x = df)
#' wb$add_data_validation(2,
#' col = 1, rows = 2:12, type = "date",
#' wb$add_data_validation(2, dims = "B2:B12", type = "date",
olivroy marked this conversation as resolved.
Show resolved Hide resolved
#' operator = "greaterThanOrEqual", value = as.Date("2016-01-01")
#' )
#' wb$add_data_validation(2,
Expand Down
16 changes: 10 additions & 6 deletions R/converters.R
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,26 @@ int2col <- function(x) {
sapply(x, int_to_col)
}

#' @name col2int
#' @title Convert Excel column to integer
#' @description Converts an Excel column label to an integer.
#' Convert Excel column to integer
#'
#' Converts an Excel column label to an integer.
#'
#' @param x A character vector
#' @return An integer column label (or `NULL` if `x` is `NULL`)
#' @export
#' @examples
#' col2int(LETTERS)
col2int <- function(x) {

if (is.null(x)) {
return(NULL)
}
olivroy marked this conversation as resolved.
Show resolved Hide resolved
if (is.numeric(x) || is.integer(x) || is.factor(x))
return(as.numeric(x))
return(as.integer(x))

if (!is.character(x)) {
stop("x must be character")

if (any(is.na(x)))
if (anyNA(x))
stop("x must be a valid character")
}

Expand Down
Loading