I would like to change the facet labels, such that I have greek letters on the y axis and normal text on the x axis. The testing data is:
testdata<-data.frame(Method2=c("a","a","b","b"),
gamma=c(0,1,0,1),values=c(1,2,3,4),x=rep(1,4),y=rep(1,4))
testplot2<-ggplot(data=testdata,aes(x=Method2,y=gamma))
testplot2<-testplot2+facet_grid(gamma~Method2 )
testplot2+geom_point()
So far I have tried the following in many differnt constellations and I'm getting rather desperate: 1) To change the names in the data frame with the paste expression and I used label_parsed without much success.
gamma<- factor(sapply(testdata$gamma, function(n){
if(n %in% c("0")) paste(expression(gamma),"0") else
if(n %in% c("1")) paste(expression(gamma),"1")
}), levels=c(paste(expression(gamma),"0"),
paste(expression(gamma),"1")
))
testdata$gamma <- gamma
2) And I have tried to use a labeller with
my.label_bquote <- function (expr1 = (gamma == .(x)),expr2 = x)
{
quoted1<- substitute(expr1)
function(variable, value) {
value <- as.character(value)
browser()
if(variable == gamma)
lapply(value, function(x) eval(substitute(bquote(expr1, list(x = x)),list(expr1 = quoted1))))
else if(variable == Method2){
value[value=="a"] <- "Whatever"
value[value=="b"] <- "Whatever2"
}
return(value)
}
}
which is a changed form of a previous answer given to a similar question: Facet labels involving a greek symbol
Would be grateful for any help!