Skip to content

Commit

Permalink
sql engine now correctly prints table with NA in first column
Browse files Browse the repository at this point in the history
Previously, `diff()` would return `NA` which does not work with `==` for comparaison.

closes #2207
  • Loading branch information
cderv committed Jan 3, 2023
1 parent b1ce0c7 commit ec4d685
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: knitr
Type: Package
Title: A General-Purpose Package for Dynamic Report Generation in R
Version: 1.41.7
Version: 1.41.8
Authors@R: c(
person("Yihui", "Xie", role = c("aut", "cre"), email = "[email protected]", comment = c(ORCID = "0000-0003-0645-5666")),
person("Abhraneel", "Sarma", role = "ctb"),
Expand Down
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

- Devices from the package **cairoDevice** (`Cairo_pdf`, `Cairo_png`, `Cairo_ps`, `Cairo_svg`) are no longer supported since the package has been archived on CRAN for more than a year (thanks, @jessekps, #2204).

## BUG FIXES

- sql engine now correctly prints table with `NA` in first column (thanks, @mariusbommert, #2207)

# CHANGES IN knitr VERSION 1.41

## NEW FEATURES
Expand Down
2 changes: 1 addition & 1 deletion R/engine.R
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ eng_sql = function(options) {

# force left alignment if the first column is an incremental id column
first_column = display_data[[1]]
if (is.numeric(first_column) && length(first_column) > 1 && all(diff(first_column) == 1))
if (is.numeric(first_column) && length(first_column) > 1 && all(identical(diff(first_column), 1)))

This comment has been minimized.

Copy link
@yihui

yihui Jan 3, 2023

Owner

x == 1 and identical(x, 1) are not equivalent (I mean x = diff(first_column) here). First, x can be a vector of length > 1, e.g., c(1, 1, 1). Second, x can be integer, e.g., 1L.

This has been amended in 3c87d2d.

This comment has been minimized.

Copy link
@cderv

cderv Jan 3, 2023

Author Collaborator

Oh indeed...😞 sorry. I should have done a PR for review. I would have seen the knitr example failure. thanks for amending !

This comment has been minimized.

Copy link
@yihui

yihui Jan 3, 2023

Owner

No worries. A direct commit is totally fine to me. No need to prepare a PR for this small problem.

This comment has been minimized.

Copy link
@cderv

cderv Jan 3, 2023

Author Collaborator

Yeah - that is what you told me in the past, and I still get that in mind every time I am doing such in your repo!
But like in this case, sometimes it is a miss. A PR makes it easier to review and CI to be run for checks.

But, I guess you read every commit in knitr anyway, so that is a kind of review 😉

This comment has been minimized.

Copy link
@yihui

yihui Jan 3, 2023

Owner

Yes, your commits will always be reviewed, so don't worry :)

display_data[[1]] = as.character(first_column)

# wrap html output in a div so special styling can be applied
Expand Down

0 comments on commit ec4d685

Please sign in to comment.