我有一份包含两个值的报告 - 项目和供应商。knitr
(1.16)的上一次迭代kable
按预期将表格输出到 pdf 和 HTML 文档中,但是更新版本输出的是列表代码,而不是列表值。
vTable <- structure(list(Item = c("Item 4", "Item C", "Item_A", "Item_B",
"Item_B_raw"), Vendors = structure(list(`1` = c("Vendor 3", "Vendor_1",
"Vendor_2", "Vendor4"), `2` = c("Vendor4", "Vendor 3", "Vendor_2",
"Vendor_1", "Vendor 5."), `3` = c("Vendor 5.", "Vendor4", "Vendor_2"
), `4` = c("Vendor_1", "Vendor4", "Vendor 5."), `5` = c("Vendor_2",
"Vendor 5.", "Vendor4", "Vendor 3")), .Names = c("1", "2", "3",
"4", "5"))), .Names = c("Item", "Vendors"), row.names = c(NA,
-5L), class = "data.frame")
vtable
Item Vendors
1 Item 4 Vendor 3, Vendor_1, Vendor_2, Vendor4
2 Item C Vendor4, Vendor 3, Vendor_2, Vendor_1, Vendor 5.
3 Item_A Vendor 5., Vendor4, Vendor_2
4 Item_B Vendor_1, Vendor4, Vendor 5.
5 Item_B_raw Vendor_2, Vendor 5., Vendor4, Vendor 3
使用knitr_1.6,
kable(vTable)
|Item |Vendors |
|:----------|:------------------------------------------------|
|Item 4 |Vendor 3, Vendor_1, Vendor_2, Vendor4 |
|Item C |Vendor4, Vendor 3, Vendor_2, Vendor_1, Vendor 5. |
|Item_A |Vendor 5., Vendor4, Vendor_2 |
|Item_B |Vendor_1, Vendor4, Vendor 5. |
|Item_B_raw |Vendor_2, Vendor 5., Vendor4, Vendor 3 |
但是knitr_1.20当前迭代的输出:
kable(vTable)
|Item |Vendors |
|:----------|:-------------------------------------------------------------|
|Item 4 |c("Vendor 3", "Vendor_1", "Vendor_2", "Vendor4") |
|Item C |c("Vendor4", "Vendor 3", "Vendor_2", "Vendor_1", "Vendor 5.") |
|Item_A |c("Vendor 5.", "Vendor4", "Vendor_2") |
|Item_B |c("Vendor_1", "Vendor4", "Vendor 5.") |
|Item_B_raw |c("Vendor_2", "Vendor 5.", "Vendor4", "Vendor 3") |
我将 kable_1.6 函数粘贴到 r 脚本中,将其移至新硬件,将其分配给“my_kable”,但它返回了Error in pandoc_to() : could not find function "pandoc_to"
. 我尝试直接编辑该函数,删除x = replace_na(to_character(as.matrix(x)), is.na(x))
并粘贴上一行x = replace_na(base::format(as.matrix(x), trim = TRUE, justify = "none"), is.na(x))
以查看是否是有问题的位,但仍然出现 pandoc_to 错误。
- 如何调整我的 data.frame 代码来纠正这个问题?
- 在编辑函数时,我在哪里偏离轨道?