在表格代码中添加R降价脚注

gg58donl  于 2023-03-05  发布在  其他
关注(0)|答案(1)|浏览(135)

我正纠结于如何在我的r markdown文档的r块中使用[^1]个脚注。我有一个表,我需要向其中添加一些脚注,但我不知道如何添加它们。我希望1下标显示在单词“Pay”的末尾旁边我在尝试向“key_points”列中的第一个条目添加脚注时尝试了以下代码:

mainPoints <- data.frame(key_points = c(paste0("Median Pay", [^1], "has increased by ", YearChangePct, "%"),
                                        paste0("Top decile Pay: £", TopDecile,"\nBottom decile Pay: £", BottomDecile),
                                        paste0(PayRisePct, "% of BLUB staff received a pay\nincrease between ", currentyear - 1, " and ", currentyear),
                                        paste0("Gender Pay gap is ", GenderPayGap, "%")),
                         Commentary = c(paste0("The average (median full-time equivalent) pay of BLUB staff is £", CurrentYearMedian, " which is an increase of ", YearChangePct, "% on the equivalent figure for ", currentyear -1, ". The overall pay award for the BLUB for ", currentyear -1, " was 1%."),
                                        paste0("Pay of £", BottomDecile, " would put someone in the bottom 10% of BLUB staff, whereas pay of £", TopDecile, " would put someone in the top 10% of BLUB staff."),
                                        paste0("The extent of the increase varied between grades: ", AApct, "% of AA staff received a pay increase between 0.1% and 1.9%. ", IND2pct,"% of Industrial 2 staff received a pay increase between 4.0% and 5.9%."),
                                        paste0("There continues to be a gap between male and female pay in the BLUB – the median pay for females is ", GenderPayGap, "% lower than the median pay for males.")))

names(mainPoints) <- c("Key Points", "Commentary")
cngwdvgl

cngwdvgl1#

插入符号必须在方括号之前:^[footnote content]
您可以将其包含在字符串中:"Median Pay^[footnote content] has increased by "
通过knitr::kable(mainPoints)传递您的表将完成这项工作:

---
output: html_document
---

Footnote in cell:

```{r, echo = F}
mainPoints <- data.frame(Key_points = c("Median pay^[footnote content]", "Top decile"),
                         Commentary = c("Comment 1", "Comment 2"))

knitr::kable(mainPoints)

![](https://i.stack.imgur.com/BEJIT.png)

相关问题