I have the following vector:
percentage <-c(-97, -97, -38, -4, 12)
I then use this function to format the numbers and convert them to text:
percent_fun <- function(x, digits = 0, format = "f", ...) {
  paste0(formatC(x, format = format, digits = digits,...), "%")
}
percentage<-percent_fun(percentage)
The intention is to further use this in a chart. My question is how I can specify in the above function to use 'Times New Roman' and make the size of the fonts/percentages equal to 8.
Here is what I plot:
structure(list(shares = c(0.39, 3.04, 9.32, 22.29, 64.97, 0.01, 
0.11, 5.83, 21.4, 72.64), quantile = structure(c(4L, 1L, 2L, 
3L, 5L, 4L, 1L, 2L, 3L, 5L), .Label = c("2nd Quantile", "3rd Quantile", 
"4nd Quantile", "Poorest 20%", "Richest 20%"), class = "factor"), 
    case = structure(c(1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L
    ), .Label = c("No Debt", "With Debt"), class = "factor")), row.names = c(NA, 
-10L), class = "data.frame")
 p<-ggplot(df_cum, aes(fill = case , quantile, shares)) + geom_bar(position =
                                                                    "dodge", stat = "identity") +
  scale_x_discrete(limits = c(
    "Poorest 20%",
    "2nd Quintile",
    "3rd Quintile",
    "4nd Quintile",
    "Richest 20%"
  )) +
  scale_fill_manual("",values = rev(RColorBrewer::brewer.pal(3,'Blues')), labels = c("Before Public Debt Shock", "Aefore Public Debt Shock")) +
  xlab("Quintile") +
  ylab("Wealth Shares (%)") +
  theme_minimal()+
  theme(text =element_text(family="Times New Roman"),
        axis.title=element_text(size=8),
        axis.title.y = element_text(margin = margin(t = 0, r = 10, b = 0, l = 0)),
        plot.caption=element_text(size = 8, hjust=0),
        #legend.position="bottom", legend.box = "horizontal",
        legend.position=c(0.2,0.9), legend.box = "horizontal",
        legend.background = element_blank(),
        legend.key = element_blank(),
        legend.text = element_text(size = 8),
        legend.title.align = 0,
        legend.title = element_blank(),
        panel.border = element_blank(),
        panel.background = element_blank(),
        axis.title.x = element_blank()) +
  guides(colour=guide_legend(nrow=2))
print(p)
y = rep(c(3, 5, 13, 25, 75),2)
x = rep(c(1:5), 2)
label = rep(percentage, 2) 
p1 <- p + geom_text(x=x, y=y+2, label=label)
p1 + geom_errorbarh(aes(xmax = (x + 0.3), xmin = (x - 0.3), y = y), height = 0.5) 
print(p1)
