我有以下dataframe
:R - ReporteRs包。是否可以将条件格式应用于文本?
> View(AuthorsMM)
Autor # Sentiment
1 Autor 1 33 J
2 Autor 2 33 J
3 Autor 3 22 K
4 Autor 4 18 L
5 Autor 5 16 L
6 Autor 6 15 K
7 Autor 7 15 L
8 Autor 8 15 K
9 Autor 9 15 K
10 Autor 10 14 K
我现在用的是包ReporteRs
发送此data.frame为flextable
到PowerPoint:
我与followig文本属性定义感悟柱:
AuthorsMM_ft[, 3] = textProperties(color = 'white', font.weight = 'bold', font.family = 'Wingdings', font.size = 12)
它使Powerpoint显示不同的表情(因为o f Wingdings trueType)根据列的内容。
但是,我想根据内容不同地将不同的颜色(绿色,黄色,红色)应用于文本。因此:
如果(观点== “J”),那么textProperties(颜色= '绿色', font.weight = '粗体',font.family = '宋体',font.size = 12)
如果(观点== “K”),那么textProperties(颜色= '黄色', font.weight = '粗体',font.family = '宋体',font.size = 12)
if(Sentiment ==“L”)then textProperties(颜色= '红色', font.weight = '粗体',font.family = '宋体',font.size = 12)
就这么可利用该包?
您可以使用'dput(AuthorsMM)'使示例更容易重现 – epo3