在显示 data.table 时,如何指示 R 将字符列中的文本左对齐?
How can I instruct R to left justify the text in a character column when displaying a data.table?
我该如何指导 R to left justify the text in a character column when displaying a data.table?
例如,我如何指示 R 在以下输出中左对齐列“文本”,使其与所需的输出相匹配?
library(data.table)
(data1 <- data.table(text = c("AAAAAA", "B", "C"), number = c(1, 2, 3)))
#> text number
#> 1: AAAAAA 1
#> 2: B 2
#> 3: C 3
由 reprex package (v2.0.1)
于 2022-02-10 创建
期望的输出:
#> text number
#> 1: AAAAAA 1
#> 2: B 2
#> 3: C 3
您可以将 justify = "left"
参数传递给 print.data.table
:
print(data1,justify="left")
text number
<char> <num>
1: AAAAAA 1
2: B 2
3: C 3
我该如何指导 R to left justify the text in a character column when displaying a data.table?
例如,我如何指示 R 在以下输出中左对齐列“文本”,使其与所需的输出相匹配?
library(data.table)
(data1 <- data.table(text = c("AAAAAA", "B", "C"), number = c(1, 2, 3)))
#> text number
#> 1: AAAAAA 1
#> 2: B 2
#> 3: C 3
由 reprex package (v2.0.1)
于 2022-02-10 创建期望的输出:
#> text number
#> 1: AAAAAA 1
#> 2: B 2
#> 3: C 3
您可以将 justify = "left"
参数传递给 print.data.table
:
print(data1,justify="left")
text number
<char> <num>
1: AAAAAA 1
2: B 2
3: C 3