Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentarelbundock committed Jan 19, 2024
1 parent 95ecfea commit cd8c7f3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
4 changes: 3 additions & 1 deletion R/save_tt.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#' This function saves an object of class tinytable to a specified file and format, with an option to overwrite existing files.
#'
#' @param x The tinytable object to be saved.
#' @param output A string representing the path to the file where the object should be saved. The supported file formats are: .html, .png, .md, .pdf, and .tex.
#' @param output String or file path.
#' + If `output` is "markdown", "latex", or "html", the table is returned in a string as an `R` object.
#' + If `output` is a valid file path, the table is saved to file. The supported extensions are: .html, .png, .pdf, .tex and .md (with aliases .txt, .Rmd and .qmd).
#' @param overwrite A logical value indicating whether to overwrite an existing file.
#' @return invisible(TRUE)
#' @export
Expand Down
6 changes: 5 additions & 1 deletion man/save_tt.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vignettes/tutorial.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ tt(x)

## Output formats

`tinytable` can produce tables in HTML, Markdown, or LaTeX (PDF) format. To choose, we use the `output` argument:
`tinytable` can produce tables in HTML, Markdown, LaTeX, PDF, or PNG format. An appropriate output format form printing is automatically selected based on (1) whether the function is called interactively, (2) is called within RStudio, and (3) based on the output format of the Rmarkdown or Quarto document. Alternatively, users can specify the print format in `print()` or by setting a global option:

```{r}
#| eval: false
tt(x) |> print("markdown")
tt(x) |> print("html")
tt(x) |> print("latex")
```
When calling `tinytable` from a Quarto or Rmarkdown document, `tinytable` detects the output format automatically and generates an HTML or LaTeX table as appropriate. This means that we do not need to explicitly specify the `output` format.
options(tinytable_print_output = "markdown")
```

With the `save_tt()` function, users can also save tables directly to PNG images or PDF documents, or any of the basic formats. All we need to do is supply a valid file name with the appropriate extension (ex: `.png`, `.html`, `.pdf`, etc.):

Expand All @@ -69,7 +69,7 @@ tt(x) |> save_tt("path/to/file.tex")
tt(x) |> save_tt("path/to/file.md")
```

You can also use `save_tt()` to 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.
`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}
tt(x) |>
Expand Down

0 comments on commit cd8c7f3

Please sign in to comment.