search for: avg_x

Displaying 1 result from an estimated 1 matches for "avg_x".

Did you mean: avg_w
2013 Oct 12
2
Order of factors with facets in ggplot2
...ot2) library(plyr) set.seed(1) f1 <- sample(c("A", "B"), 100, replace= T) f2 <- gl(4, 25, labels = paste("M", 1:4, sep="")) x <- runif(100) df <- data.frame(f1, f2, x) #df <- df[order(df[,1]), ] df <- ddply(df, ~ f1 + f2, transform, Avg_x = mean(x)) myplot <- ggplot(df, aes(x=reorder(f2, Avg_x), x)) + geom_boxplot() + facet_wrap(~ f1, scale = "free", ncol = 1) + stat_summary(fun.y=mean, geom="point", col = "red") myplot Thanks in advance for any help! Lars. [[alternative HTML version de...