Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jan 25, 2024
1 parent e368687 commit 51cb230
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 11 deletions.
20 changes: 11 additions & 9 deletions R/style_tabularray.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,17 @@ style_tabularray <- function(x,
settings$tabularray <- trimws(gsub(",+", ",", settings$tabularray))


for (k in seq_len(nrow(settings))) {
if (all(c("i", "j") %in% colnames(settings))) {
spec <- sprintf("cell{%s}{%s}={%s}{%s},", settings$i[k], settings$j[k], span, settings$tabularray[k])
} else if ("i" %in% colnames(settings)) {
spec <- sprintf("row{%s}={%s},", settings$i[k], settings$tabularray[k])
} else if ("j" %in% colnames(settings)) {
spec <- sprintf("column{%s}={%s},", settings$j[k], settings$tabularray[k])
}
out <- tabularray_insert(out, content = spec, type = "inner")
if (!all(settings$tabularray == ",")) {
for (k in seq_len(nrow(settings))) {
if (all(c("i", "j") %in% colnames(settings))) {
spec <- sprintf("cell{%s}{%s}={%s}{%s},", settings$i[k], settings$j[k], span, settings$tabularray[k])
} else if ("i" %in% colnames(settings)) {
spec <- sprintf("row{%s}={%s},", settings$i[k], settings$tabularray[k])
} else if ("j" %in% colnames(settings)) {
spec <- sprintf("column{%s}={%s},", settings$j[k], settings$tabularray[k])
}
out <- tabularray_insert(out, content = spec, type = "inner")
}
}

# Lines are not part of cellspec/rowspec/columnspec. Do this separately.
Expand Down
13 changes: 11 additions & 2 deletions vignettes/tutorial.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ tt(x) |> save_tt("path/to/file.md")

`save_tt()` can also return a string with the table in it, for further processing in `R`. In the first case, the table is printed to console with `cat()`. In the second case, it returns as a single string as an `R` object.

```{r, eval = FALSE}
```{r}
tt(mtcars[1:10, 1:5]) |>
group_tt(
i = list(
Expand Down Expand Up @@ -590,7 +590,7 @@ The `style_tt` function allows us to customize the borders that surround eacell

Here is an example where we draw lines around every border ("t", "b", "l", and "r") of specified cells.

```{r, eval = FALSE}
```{r}
tt(x, theme = "void") |>
style_tt(
i = 0:3,
Expand All @@ -600,6 +600,15 @@ tt(x, theme = "void") |>
line_color = "orange")
```

And here is an example with horizontal rules:

```{r}
tt(x, theme = "void") |>
style_tt(i = 0, line = "t", line_color = "orange", line_width = 0.4) |>
style_tt(i = 0, line = "b", line_color = "purple", line_width = 0.2) |>
style_tt(i = 4, line = "b", line_color = "orange", line_width = 0.4)
```


# Tiny plots and images

Expand Down

0 comments on commit 51cb230

Please sign in to comment.