A really simple question (I am fairly new to R):
I have created a ggbarplot using ggpubr
package, and whilst I can get the y scale to be formatted as a percentage (e.g. 80% instead of 0.8), I am unable to change the format of the data labels.
Here is the code:
ggbarplot(x = "Trophic level",
y = "percent.present",
fill = "Structure type",
color = "Structure type",
position = position_dodge(),
ylab = "% of species that used underpasses",
ggtheme = theme_bw(),
title = "Proportion of species in area that used underpasses",
palette = "Set2",
label = TRUE, lab.nb.digits = 2) %>%
ggpar(legend = "bottom") +
yscale("percent", .format = TRUE)
And here is the resulting plot - note the labels are showing up as 0.8 instead of 80%.
How would I amend the code to format the data labels to a percentage too?
dput output here:
structure(list(`Trophic level` = c("Apex predator", "Apex predator",
"Megaherbivore", "Megaherbivore"), `Structure type` = c("All underpasses",
"Non-viaduct culverts", "All underpasses", "Non-viaduct culverts"
), percent.present = c(1, 1, 0.8, 0.2)), row.names = c(NA, -4L
), class = c("tbl_df", "tbl", "data.frame"))