2

I am trying to change the names of the panel from 0, 1, 4, ... to c("Gl", "RC", "4", "9", "16", "25" "36", "49). I have tried the labeller function but that gives "NA". Any help or direction to start is truly appreciated.

 library("ggplot2")
 library(reshape2)

  #####################################################

  req<-c(sapply(seq(0, 7) , function (x) x**2))

 err2<-c( 0.62,0.48, 0.64, 0.61, .77, .79, 0.82, 0.82)
 An2<-rep( c("II"), each=(length(req+1)))
 data2<-data.frame(req,  ErrorRate=err2,  Analysis=An2)


##############################################
 err3<-c(0.66, .46,  .69, .62, .74, .79, .81, 0.78) #.79  
 An3<-rep( c("III"), each=(length(req+1)))
 data3<-data.frame(req,ErrorRate=err3,  Analysis=An3)

 ###########################
  dat1<-rbind( data2, data3)
##############################

   P<-ggplot() +
   geom_bar(data= dat2, aes(y =ErrorRate, x = "", fill = Analysis), 
   stat="identity", color="black",
   position = position_dodge(.9)) + theme_bw()
   P+facet_grid(.~ factor.req., scales="free")

enter image description here

d.b
  • 32,245
  • 6
  • 36
  • 77
  • 1
    This should help: https://stackoverflow.com/a/34811062/7128934 – d.b Aug 21 '19 at 23:23
  • 1
    Ideally, create a variable in the data with the variable you're facetting on. Make it a factor, and change the factor labels. What labeller function have you tried? – camille Aug 22 '19 at 02:44

0 Answers0