Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Format columns with colour

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md
NotificationsYou must be signed in to change notification settings

r-lib/pillar

Repository files navigation

Lifecycle: stableR build statusCoverage statusCRAN status

pillar provides tools for styling columns of data, artfully using colour and unicode characters to guide the eye.

Due to limitations of GitHub's Markdown display, formatting cannot be shown in the README.The same content is available onhttps://pillar.r-lib.org/ with proper formatting.

Installation

# pillar is installed if you install the tidyverse package:install.packages("tidyverse")# Alternatively, install just pillar:install.packages("pillar")

Usage

pillar is a developer-facing package that is not designed for end-users. It powers theprint() andformat() methods fortibbles. It also and defines generics and helpers that are useful for package authors who create custom vector classes (seehttps://github.com/krlmlr/awesome-vctrs#readme for examples) or custom table classes (likedbplyr orsf).

library(pillar)x<-123456789*(10^c(-3,-5,NA,-8,-10))pillar(x)#><pillar>#><dbl>#>123457.#>1235.#>NA#>      1.23#>      0.0123tbl_format_setup(tibble::tibble(x))#><pillar_tbl_format_setup>#><tbl_format_header(setup)>#># A data frame: 5 × 1#><tbl_format_body(setup)>#>x#><dbl>#>1123457.#>21235.#>3NA#>4      1.23#>5      0.0123#><tbl_format_footer(setup)>

Custom vector classes

The primary user of this package istibble, which lets pillar do all the formatting work. Packages that implement a data type to be used in a tibble column can customize the display by implementing apillar_shaft() method.

library(pillar)percent<-vctrs::new_vctr(9:11*0.01, class="percent")pillar_shaft.percent<-function(x,...){fmt<-format(vctrs::vec_data(x)*100)new_pillar_shaft_simple(paste0(fmt," ",style_subtle("%")), align="right")}pillar(percent)#><pillar>#><percent>#>       9%#>      10%#>      11%

Seevignette("pillar", package = "vctrs") for details.

Custom table classes

pillar provides various extension points for customizing how a tibble-like class is printed.

tbl<-vctrs::new_data_frame(list(a=1:3), class=c("my_tbl","tbl"))tbl_sum.my_tbl<-function(x,...){c("Hello"="world!")}tbl#># Hello: world!#>a#><int>#>1     1#>2     2#>3     3

Seevignette("extending", package = "pillar") for a walkthrough of the options.


Code of Conduct

Please note that the pillar project is released with aContributor Code of Conduct. By contributing to this project, you agree to abide by its terms.

About

Format columns with colour

Topics

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Contributors22


[8]ページ先頭

©2009-2025 Movatter.jp