I have the following code using the dplyr package:
我使用dplyr包编写了以下代码:
Cholesteroldata %>%
group_by(Genotype) %>%
summarise(`W Stat` = shapiro.test(Cholesterol)$statistic,
p.value = shapiro.test(Cholesterol)$p.value)
It generates a nice formatted table in a separate window, but I'd like to put either a caption or a header on the table in that output window. Help?
它在一个单独的窗口中生成一个很好的格式化表格,但我想在该输出窗口中的表格上放置一个标题或标题。帮助?
更多回答
Look at gt
or kableExtra
or any of the other fancy-table rendering packages. FYI, once you start rendering for "fancy", it ceases to be a data.frame
that you can operate on.
看看GT或kableExtra或任何其他花哨的表格呈现包。仅供参考,一旦你开始为了“花哨”而渲染,它就不再是你可以操作的数据帧了。
Thanks! found kableExtra and was able to pipe the output from summarise to it: Cholesteroldata %>% group_by(Genotype) %>% summarise(W Stat
= shapiro.test(Cholesterol)$statistic, p.value = shapiro.test(Cholesterol)$p.value) %>% kbl(caption = "Shapiro-Wilk test by Genotype") %>% kable_classic_2(full_width = F)
谢谢!找到kableExtra并能够通过管道将输出从摘要传送到它:Cholestoldata%>%GROUP_BY(GENTYPE)%>%SUMMISTISE(W Stat=shapiro.test(胆固醇)$STATISTICATION,p.Value=shapiro.test(胆固醇)$p.Value)%>%kbl(Caption=“Shapiro-Wilk test by Gentype”)%>%kable_Classic_2(Full_Width=F)
@NatalieProwse add it as an answer! :-)
@NatalieProwse将其添加为答案!:-)
优秀答案推荐
I installed kableExtra and was able to pipe the output from summarise to it. Adding kable_classic_2 gave me a nice table, and setting full_width=F ensured it didn't span the width of the window.
我安装了kableExtra,并能够通过管道将输出从摘要传输到它。添加KABLE_CLASSIC_2可以得到一个很好的表,设置FULL_WIDTH=F可以确保它不会跨越窗口的宽度。
library("kableExtra")
Cholesteroldata %>% group_by(Genotype) %>%
summarise(W Stat = shapiro.test(Cholesterol)$statistic, p.value = shapiro.test(Cholesterol)$p.value) %>%
kbl(caption = "Shapiro-Wilk test by Genotype") %>%
kable_classic_2(full_width = F)
更多回答
我是一名优秀的程序员,十分优秀!