r - ggplot2 use toupper in aes -


i call toupper within aes call in ggplot2. example, using plantgrowth change variable group caps. i've been able change x labels caps, x axis title takes on odd title. can manually drop x axis title, seems there easier way.

edit 1: should have stated rather not change data in dataframe, i.e., d$group <- toupper(d$group). instead change labels within aes statement, if possible.

library (ggplot2) d <- plantgrowth p <- ggplot () + geom_bar (data=d, aes(toupper(x=group),y=weight),stat='identity') p <- p + theme (axis.title.x=element_blank()) #workaround drop x axis title p 

thanks -cherrytree

use levels()

library (ggplot2) d <- plantgrowth levels(d$group) = toupper(levels(d$group)) ggplot() + geom_bar(data=d, aes(x=group,y=weight), stat='identity') 

edit: not change data.frame version

library (ggplot2) d <- plantgrowth ggplot() + geom_bar(data=d, aes(x=group,y=weight), stat='identity') + scale_x_discrete(label = toupper(levels(d$group))) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -