vincentarelbundock / tinytable

Simple and Customizable Tables in `R`
https://vincentarelbundock.github.io/tinytable
GNU General Public License v3.0
196 stars 16 forks source link

`group_tt()`: multiple `i` entries is unintuitive #258

Closed vincentarelbundock closed 3 months ago

vincentarelbundock commented 4 months ago
tt(head(iris)) |>
    group_tt(i = list("Blah" = 2, "Hello" = 3)) |>
    print("markdown")

+--------------+-------------+--------------+-------------+---------+
| Sepal.Length | Sepal.Width | Petal.Length | Petal.Width | Species |
+==============+=============+==============+=============+=========+
| 5.1          | 3.5         | 1.4          | 0.2         | setosa  |
+--------------+-------------+--------------+-------------+---------+
| Blah                                                              |
+--------------+-------------+--------------+-------------+---------+
| 4.9          | 3.0         | 1.4          | 0.2         | setosa  |
+--------------+-------------+--------------+-------------+---------+
| Hello                                                             |
+--------------+-------------+--------------+-------------+---------+
| 4.7          | 3.2         | 1.3          | 0.2         | setosa  |
+--------------+-------------+--------------+-------------+---------+
| 4.6          | 3.1         | 1.5          | 0.2         | setosa  |
+--------------+-------------+--------------+-------------+---------+
| 5.0          | 3.6         | 1.4          | 0.2         | setosa  |
+--------------+-------------+--------------+-------------+---------+
| 5.4          | 3.9         | 1.7          | 0.4         | setosa  |
+--------------+-------------+--------------+-------------+---------+ 
Nenuial commented 4 months ago

I have a question related to this. I tried to have a group at i = 0 and got an error. How can I have a group that starts with the first line of the table?

Edit: I should add that I'm using Typst as output format. Looking at the markdown example above I'm wondering if there's not something going on there. I'll do some tests when I have the chance.

Nenuial commented 4 months ago

I can confirm that there is something unusual going on:

---
format: typst
---

```{r}
#| output: asis
library(tinytable)
tt(head(iris)) |>
  group_tt(i = list("Blah" = 1)) |>
  print("markdown")
library(tinytable)
tt(head(iris)) |>
  group_tt(i = list("Blah" = 1))


The markdown places the *Blah* before the first line, whereas in Typst it's placed  after the first line and the last line gets pushed down.
vincentarelbundock commented 3 months ago

Fixed on Github