https://github.com/mlverse/tabulate
Pretty Console Output for Tables
https://github.com/mlverse/tabulate
Last synced: 12 months ago
JSON representation
Pretty Console Output for Tables
- Host: GitHub
- URL: https://github.com/mlverse/tabulate
- Owner: mlverse
- License: other
- Created: 2022-02-05T12:28:11.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-16T11:25:52.000Z (over 4 years ago)
- Last Synced: 2025-07-07T13:40:40.840Z (12 months ago)
- Language: C++
- Homepage: https://mlverse.github.io/tabulate/
- Size: 794 KB
- Stars: 39
- Watchers: 3
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output:
md_document:
variant: gfm
always_allow_html: true
---
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
# Turn on ANSI colors
options(cli.num_colors = 256L)
asciicast::init_knitr_engine(
startup = quote({
library(tabulate)
}),
echo = TRUE,
echo_input = FALSE,
same_process = TRUE,
options = list(
asciicast_end_wait = 3
)
)
```
# tabulate
[](https://github.com/mlverse/tabulate/actions)
[](https://CRAN.R-project.org/package=tabulate)
[](https://cran.r-project.org/package=tabulate)
Tabulate is a thin wrapper around the [tabulate C++ library](https://github.com/p-ranav/tabulate).
It allows users to pretty print tables in the console, with support for different
font styles, colors, borders and etc. It also supports multi-bytes characters and
nesting tables.
```{asciicast demo, echo = FALSE}
#' cols: 108
#' padding_x: 5
#' padding_y: 5
tabulate::tabulate_demo()
```
## Installation
tabulate can be installed from CRAN with:
```
install.packages("tabulate")
```
You can install the development version of tabulate from [GitHub](https://github.com/) with:
``` r
# install.packages("remotes")
remotes::install_github("mlverse/tabulate")
```
## Example
The following example shows basic functionality of tabulate. Like formatting and
coloring the output. Note that color and font styles are only suppported in platforms
that support ANSI strings. For a colored version of this table see this [link](https://mlverse.github.io/tabulate/articles/unicode.html).
```{asciicast table}
library(tabulate)
department <- tabulate_table() %>%
table_add_row(c("Research", "Engineering"))
employees <- tabulate_table() %>%
table_add_row(
c("Emp. ID", "First Name", "Last Name", "Department / Business Unit")) %>%
table_add_row(c("101", "Donald", "Patrick", "Finance")) %>%
table_add_row(
c("102", "Rachel", "Williams",
"Marketing and Operational\nLogistics Planning")) %>%
table_add_row(c("103", "Ian", "Jacob", department))
employees[,1] %>%
format_font_style("bold") %>%
format_font_color("red") %>%
format_font_align("right")
employees[,4] %>% format_font_align("center")
print(employees)
```
See the [example gallery](https://mlverse.github.io/tabulate/articles/) for more.