gpt4 book ai didi

r - 使用 expss 包调整列宽

转载 作者:行者123 更新时间:2023-12-04 13:21:10 24 4
gpt4 key购买 nike

我一直在用expss经常并发现它非常有用,但是,在某些情况下,我的列值是不适合默认列宽的长字符串。

例如,下图显示了需要加宽的列。什么 htmlTables() expss 中的选项可以用来加宽列吗?
enter image description here

最佳答案

有几种方法可以增加第一列的宽度。尝试
以下之一:

library(expss)
expss_output_viewer()

data(mtcars)
mtcars = apply_labels(mtcars,
mpg = "Miles/(US) gallon",
cyl = "Number of cylinders",
disp = "Displacement (cu.in.)",
hp = "Gross horsepower",
drat = "Rear axle ratio",
wt = "Weight (1000 lbs)",
qsec = "1/4 mile time",
vs = "Engine",
vs = c("V-engine" = 0,
"Straight engine" = 1),
am = "Transmission",
am = c("Automatic" = 0,
"Manual"=1),
gear = "Number of forward gears",
carb = "Number of carburetors"
)


# straightforward column width adjustment
calc_cro_cpct(mtcars, list(vs, am), list(total(), vs %nest% am)) %>%
htmlTable(., css.cell = c("width: 250px", # first column width
rep("width: 50px", ncol(.) - 1)) # other columns width
)

# row labels padding
calc_cro_cpct(mtcars, list(vs, am), list(total(), vs %nest% am)) %>%
htmlTable(padding.rgroup = paste(rep(" ", 20), collapse = ""))

# disable row grouping
calc_cro_cpct(mtcars, list(vs, am), list(total(), vs %nest% am)) %>%
htmlTable(row_groups = FALSE)

参数 css.cellpadding.rgroup记录在
htmlTable 包其中 expss用于呈现 HTML 表格表示(请参阅
?htmlTable::htmlTable)。

关于r - 使用 expss 包调整列宽,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52501414/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com