Skip to content

Commit

Permalink
better fix (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanMarvin committed Aug 17, 2023
1 parent 4683e56 commit a23bcd8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/read.R
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ wb_to_df <- function(
keep_rows <- keep_rows[keep_rows %in% rnams]

# reduce data to selected cases only
if (!is.null(cols) && !is.null(rows) && !missing(dims))
if (length(keep_rows) && length(keep_cols))
cc <- cc[cc$row_r %in% keep_rows & cc$c_r %in% keep_cols, ]

cc$val <- NA_character_
Expand Down
11 changes: 11 additions & 0 deletions tests/testthat/test-wb_functions.R
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,14 @@ test_that("cols return order is correct", {
expect_equal(exp, got)

})

test_that("missings cells are returned", {

wb <- wb_workbook()$add_worksheet()$add_data(x = "a", dims = "Z100")

expect_silent(got <- wb_to_df(wb, col_names = FALSE, rows = 1, cols = 1))
expect_silent(got <- wb_to_df(wb, col_names = FALSE, rows = c(1, 4, 10), cols = c(2, 5, 10)))

expect_silent(got <- wb_to_df(wb, col_names = FALSE, rows = c(101), cols = c(27)))

})

0 comments on commit a23bcd8

Please sign in to comment.