首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >用expss封装调整柱宽

用expss封装调整柱宽
EN

Stack Overflow用户
提问于 2018-09-25 15:08:40
回答 1查看 412关注 0票数 3

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

例如,下面的图像显示一个需要加宽的列。可以使用expss中的哪些expss选项来拓宽列?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-09-25 15:21:24

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

代码语言:javascript
复制
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用于呈现htmlTable表示(参见?htmlTable::htmlTable)。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/52501414

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档