r - 包中的年份::huxtable 表脚注默认为科学概念
问题描述
我正在尝试使用 package::huxtable 在表格中添加一个包含 4 位数年份的脚注。年份以科学计数法输出。我在参考表格正文中的数字和我的问题时遇到了同样的问题, @katia 解释了发生了什么。但现在我被困在试图解决同样的问题,但在表格的脚注中:
options(scipen = 100, digits = 10)
library(huxtable)
t <- huxtable(mtcars[1:5, 1:2])
number_format(t) <- 1
add_footnote(t, "No cars in 1776")
脚注打印为:
# No cars in 1.78e+03
我不知道发生了什么 - number_format() 将整个表格的小数位设置为 1。或者应该是。删除它会将整个表格恢复为科学计数法。将 1776 放在引号中会导致错误:
Error: unexpected numeric constant in "add_footnote(t, "No cars in "1776"
非常感谢任何指针/帮助!
解决方案
footnote
in ahuxtable
带有自己的属性-您可以传递其他参数,然后将其传递给`set_cell_properties
参数
... 其他属性,传递给脚注单元格的 set_cell_properties。
指定number_format
为add_footnote
应该工作的附加参数
add_footnote(t, "No cars in 1776", number_format = 0)
# 21.0 6.0
# 21.0 6.0
# 22.8 4.0
# 21.4 6.0
# 18.7 8.0
# ───────────────────────────────
# No cars in 1776
# Column names: mpg, cyl
推荐阅读
- php - 使用动态子元素从 xml 元素中获取数据
- javascript - 如何在 Chart.js 中使用 showAllTooltips 和模式
- apache-spark - 使用两台不同的 Windows 机器设置 Spark 独立集群
- python-3.x - PyMySQL with Flask: %d format: a number is required, not str with stored procedure
- javascript - 在 jQuery 中同时显示所有错误消息
- java - String = 运算符引用或在这种情况下创建新的 String 对象
- asp.net - asp.net 4.6.1 中的 GridView 错误?
- sql - DAX 从开始和结束日期获取时间序列
- ios - 观看 OS 钥匙串共享
- html - 如何使 CSS Sprites 为移动设备垂直对齐