Skip to content

Commit 62869ab

Browse files
issue #609
1 parent 784f9a9 commit 62869ab

File tree

6 files changed

+62
-36
lines changed

6 files changed

+62
-36
lines changed

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Package: tinytable
22
Type: Package
33
Title: Simple and Configurable Tables in 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', and 'Typst' Formats
44
Description: Create highly customized tables with this simple and dependency-free package. Data frames can be converted to 'HTML', 'LaTeX', 'Markdown', 'Word', 'PNG', 'PDF', or 'Typst' tables. The user interface is minimalist and easy to learn. The syntax is concise. 'HTML' tables can be customized using the flexible 'Bootstrap' framework, and 'LaTeX' code with the 'tabularray' package.
5-
Version: 0.15.0.2
5+
Version: 0.15.0.3
66
Imports:
77
methods
88
Depends:
@@ -44,5 +44,5 @@ Authors@R: c(
4444
comment = c(ORCID = "0000-0003-2042-7063")))
4545
License: GPL (>= 3)
4646
Encoding: UTF-8
47-
RoxygenNote: 7.3.2
47+
RoxygenNote: 7.3.3
4848
Roxygen: list(markdown = TRUE)

NEWS.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# News
22

3+
## 0.15.0.2
4+
5+
Bugs:
6+
7+
* `style_tt()` with a logical matrix containing all `FALSE` values no longer throws an error (Issue #609, thanks to @EinMaulwurf).
8+
39
## 0.15.0.1
410

511
Misc:

R/style_tt.R

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,22 @@ style_tt_lazy <- function(
322322
if (!is.matrix(i) || !is.logical(i)) {
323323
settings <- process_align_argument(x, settings, align)
324324
} else {
325-
settings$align <- NA_character_
325+
if (nrow(settings) > 0) {
326+
settings$align <- NA_character_
327+
}
326328
}
327329

328330
# sort column: important for bind
329331
cols <- unique(c("i", "j", sort(colnames(settings))))
330332
settings <- settings[, cols, drop = FALSE]
331333

332-
if (nrow(out@style) == 0) {
333-
out@style <- settings
334-
} else {
335-
out@style <- rbind(out@style, settings)
334+
# Only add settings if there are rows to add
335+
if (nrow(settings) > 0) {
336+
if (nrow(out@style) == 0) {
337+
out@style <- settings
338+
} else {
339+
out@style <- rbind(out@style, settings)
340+
}
336341
}
337342

338343
if (is.function(finalize)) {

README.md

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22

33
<p align="center">
4+
45
<img src="man/figures/gallery/tinytable_gallery.gif" height = "250" class = "center">
56
<br> <!-- badges: start -->
67
<a href = "https://github.com/vincentarelbundock/tinytable/blob/main/LICENSE.md" target = "_blank"><img src="https://img.shields.io/badge/license-GPLv3-blue"></a>
@@ -12,14 +13,14 @@
1213
## What?
1314

1415
`tinytable` is a small but powerful `R` package to draw beautiful tables
15-
in a variety of formats: HTML, LaTeX, Word[1], PDF, PNG, Markdown, and
16+
in a variety of formats: HTML, LaTeX, Word[^1], PDF, PNG, Markdown, and
1617
Typst. The user interface is minimalist and easy to learn, while giving
1718
users access to powerful frameworks to create endlessly customizable
1819
tables.
1920

2021
<https://vincentarelbundock.github.io/tinytable/>
2122

22-
> **Note**
23+
> [!NOTE]
2324
>
2425
> The documentation on this website uses the latest development version
2526
> of `tinytable`. This version can normally be installed from
@@ -49,25 +50,24 @@ ecosystem. Why release a new one? As [the maintainer of
4950
`modelsummary`](https://modelsummary.com), I needed a table-drawing
5051
package which was:
5152
52-
- *Simple*: Streamlined, consistent, and uncluttered user interface,
53-
with few functions to learn.
54-
- *Flexible*: Expressive frameworks to customize tables in HTML and
55-
LaTeX formats.[2]
56-
- *Zero-dependency*: Avoid importing any other `R` package.[3]
57-
- *Concise*: Draw beautiful tables without typing a lot of code.
58-
- *Safe*: User inputs are checked thoroughly, and informative errors
59-
are returned early.
60-
- *Maintainable*: A small code base which does not rely on too many
61-
complex regular expressions.
62-
- *Readable*: HTML and LaTeX code should be human-readable and
63-
editable.
64-
- *Free*: This package will always be free. Tiny tables for a tiny
65-
price!
53+
- *Simple*: Streamlined, consistent, and uncluttered user interface,
54+
with few functions to learn.
55+
- *Flexible*: Expressive frameworks to customize tables in HTML and
56+
LaTeX formats.[^2]
57+
- *Zero-dependency*: Avoid importing any other `R` package.[^3]
58+
- *Concise*: Draw beautiful tables without typing a lot of code.
59+
- *Safe*: User inputs are checked thoroughly, and informative errors are
60+
returned early.
61+
- *Maintainable*: A small code base which does not rely on too many
62+
complex regular expressions.
63+
- *Readable*: HTML and LaTeX code should be human-readable and editable.
64+
- *Free*: This package will always be free. Tiny tables for a tiny
65+
price!
6666
6767
To achieve these goals, the design philosophy of `tinytable` rests on
6868
three pillars:
6969
70-
1. *Data is separate from style.* The code that this package creates
70+
1) *Data is separate from style.* The code that this package creates
7171
keeps the content of a table separate from the style sheet that
7272
applies to its cells. This is in contrast to other `R` packages that
7373
modify the actual text in each cell to style it. Keeping data and
@@ -76,13 +76,13 @@ three pillars:
7676
developers to keep a simpler code base, with minimal use of messy
7777
regular expressions.
7878
79-
2. *Flexibility.* Usersneeds are extremely varied, and a
79+
2) *Flexibility.* Usersneeds are extremely varied, and a
8080
table-drawing package must be flexible enough to accomodate
8181
different ideas. To achieve this, `tinytable` builds on
8282
battle-tested and versatile frameworks like `Bootstrap` for HTML and
8383
`tabularray` for LaTeX.
8484
85-
3. Lightweight. Some of the most popular table-drawing packages in the
85+
3) Lightweight. Some of the most popular table-drawing packages in the
8686
`R` ecosystem are very heavy: A single `library()` call can
8787
sometimes load upwards of 65 `R` packages. In contrast, `tinytable`
8888
imports zero 3rd party `R` package by default.
@@ -135,17 +135,17 @@ tt(x,
135135

136136
## Tutorial
137137

138-
The `tinytable` 0.15.0 tutorial will take you much further. It is
138+
The `tinytable` 0.14.0 tutorial will take you much further. It is
139139
available in HTML and PDF formats at:
140140
<https://vincentarelbundock.github.io/tinytable/>
141141

142-
[1] Styling options in Word are somewhat limited. See the FAQ page and
143-
the `style_tt()` documentation for details.
142+
[^1]: Styling options in Word are somewhat limited. See the FAQ page and
143+
the `style_tt()` documentation for details.
144144

145-
[2] Other formats like Markdown and Typst are also available, but less
146-
flexible.
145+
[^2]: Other formats like Markdown and Typst are also available, but less
146+
flexible.
147147

148-
[3] Some extra packages can be imported to access specific
149-
functionality, such as integration with Quarto, inserting `ggplot2`
150-
objects as inline plots, and saving tables to PNG images or PDF
151-
documents.
148+
[^3]: Some extra packages can be imported to access specific
149+
functionality, such as integration with Quarto, inserting `ggplot2`
150+
objects as inline plots, and saving tables to PNG images or PDF
151+
documents.

inst/tinytest/test-style.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,18 @@ expect_snapshot_print(t[["html"]], "style-align_partial.html")
9696
expect_snapshot_print(t[["latex"]], "style-align_partial.tex")
9797
expect_snapshot_print(t[["typst"]], "style-align_partial.typ")
9898
expect_snapshot_print(t[["markdown"]], "style-align_partial.md")
99+
100+
101+
# logical matrix with all FALSE values should not error
102+
testdata <- data.frame(
103+
names = c('a', 'b', 'c', 'd', 'e'),
104+
values1 = c(1, 2, 3, 4, 5),
105+
values2 = c(6, 7, 8, 9, 10)
106+
)
107+
testdata_override <- matrix(FALSE, nrow = nrow(testdata), ncol = ncol(testdata))
108+
result <- testdata |>
109+
tt() |>
110+
style_tt(i = testdata_override, background = "red") |>
111+
save_tt("html")
112+
expect_true(is.character(result))
113+
expect_true(nchar(result) > 0)

man/style_tt.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)