与 stargazer 赚取百分比 table

Make a percentage table with stargazer

我有这样的数据,df1:

Product Relative_Value
Car     0.12651458
Plane   0.08888552
Tank    0.03546231
Bike    0.06711630
Train   0.06382191

Relative_Value是产品总销量的百分比。我使用 stargazer(df1, summary=FALSE, rownames=TRUE) 获取乳胶代码来制作漂亮的 table 数据。但是我如何让 R 或 TeXstudio 理解 Relative_Value 应该格式化为百分比而不是小数?

您可以使用 scales 包中的 percent()

library(scales)

df1 <- df1 %>%
    mutate(Relative_Value = percent(Relative_Value))

注意 percent() 将列类型更改为字符