Continuation to this question.
The labels in facet_wrap()
contains numbers with different decimal places. I used glue
R package. The codes and the associated figures are given below.
data <- data.frame(N = runif(30, 200, 600),
powers = runif(30, 0.03, 0.06),
low = runif(30, 0.03, 0.04),
upp = runif(30, 0.04, 0.05),
q = rep(c(0.02,0.04,0.06,0.08,0.10,0.12), 5))
N = data[,1]
p = data[,2]
q = data[,3]
low = data[,4]
upp = data[,6]
powers = data[,5]
ggplot(data,aes("x" = N, "y" = powers))+
geom_point() + geom_line() +
facet_wrap(~glue('phi[1]*" = {q}"'), nrow = 2, labeller = label_parsed)+
labs("y" = "Powers")
How do I make sure that the labels wrote $\phi_1 = 0.10$ instead of $\phi_1 = 0.1$?
With format
and nsmall
:
... +
facet_wrap(~ glue('phi[1]*" = {format(round(q, 2), nsmall = 2)}"') +
...