R语言【cli】——ansi_columns():把字符向量格式化为多个列

Package cli version 3.6.0


Description

这个函数有助于ANSI样式字符串的多列输出。它可以很好地与boxx()一起工作。


Usage

ansi_columns(
  text,
  width = console_width(),
  sep = " ",
  fill = c("rows", "cols"),
  max_cols = 4,
  align = c("left", "center", "right"),
  type = "width",
  ellipsis = symbol$ellipsis
)

Arguments

参数【text】:字符矢量格式。每个元素将被格式化为表格的一个单元格。

参数【width】:屏幕的宽度。

参数【sep】:列之间的分隔符。它可能有ANSI样式。

参数【fill】:是按行填充还是按列填充。

参数【max_cols】:要使用的最大列数。不会再用了,即使还有空间。

参数【align】:列内的对齐。

参数【type】:传递给ansi_nchar()和ansi_align()。你很可能想要默认的“width”。

参数【ellipsis】:要追加到截断字符串的字符串。如果不想要标记,请提供空字符串。


Example

fmt <- ansi_columns(
  paste(col_red("foo"), 1:10),
  width = 50,
  fill = "rows",
  max_cols=10,
  align = "center",
  sep = "   "
)
boxx(fmt, padding = c(0,1,0,1), header = col_cyan("Columns"))
┌ Columns ───────────────────────────────────────────┐
│  foo 1     foo 2     foo 3     foo 4     foo 5     │
│  foo 6     foo 7     foo 8     foo 9     foo 10    │
└────────────────────────────────────────────────────┘

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-01-20 18:04:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-01-20 18:04:03       100 阅读
  3. 在Django里面运行非项目文件

    2024-01-20 18:04:03       82 阅读
  4. Python语言-面向对象

    2024-01-20 18:04:03       91 阅读

热门阅读

  1. 文件包含漏洞讲解

    2024-01-20 18:04:03       69 阅读
  2. 【python】Python极简速通-递归

    2024-01-20 18:04:03       51 阅读
  3. MongoDB面试系列-02

    2024-01-20 18:04:03       52 阅读
  4. Python——turtle库笔记①

    2024-01-20 18:04:03       71 阅读
  5. C++入门学习(二)注释

    2024-01-20 18:04:03       51 阅读
  6. pytest.ini 配置

    2024-01-20 18:04:03       63 阅读
  7. 网络爬虫基本原理的介绍

    2024-01-20 18:04:03       63 阅读
  8. Chrome 浏览器 Manifest V3 版本中 scripting API 解析

    2024-01-20 18:04:03       56 阅读