r - ggplot2 facet_wrap with mathematical expression -


using facet_wrap(), want label each individual plot mathematical expression:

library(ggplot2)  x       <- rnorm(100, 50, 10) y       <- rnorm(100, 50, 10) grp     <- rep(c("a", "b", "c", "d"), each=25) test.df <- data.frame(grp, x, y) mean.df <- aggregate(test.df[c("x", "y")], test.df["grp"], mean)  p <- ggplot(test.df) +      geom_point(aes(x=x, y=y, col=grp)) +       facet_wrap(~ grp) +      geom_text(data=mean.df, aes(x=x, y=y, label=paste("xbar=", round(x,1)))) p 

i want \bar(x) instead of xbar. tried expression(), get: "cannot coerce class ""expression"" data.frame".

using

geom_text(data = mean.df, parse = true,           aes(x = x, y = y, label = paste("bar(x) ==", round(x, 1)))) 

helps.

enter image description here


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

javascript - Get parameter of GET request -

javascript - Twitter Bootstrap - how to add some more margin between tooltip popup and element -