1

I have a data frame with 4 variables. I plotted the 4 variables using boxplot and facet_grid(intg~del)

D = read.table('data.dat')
names(D) = c('size','mut','intg','del')
ggplot(D,aes(x=mut,y=size,fill=as.factor(mut))) + 
geom_boxplot() + 
facet_grid(intg~del)

I want to add a horizontal line to each facet the value is a new variable set as the following:

  D$exp<-D$intg+60-(D$del*(D$ig+60))

Data:

   size  mutation intg del  expected
   96        0     0   0.2      48   #facet 1
   95        0     0   0.2      48   #facet 1
   90        0.15  0   0.2      48   #facet 1
   73        0.15  0   0.4      36   #facet 2
   62        0.3   10  0.4      42   #facet 3
   82        0.3   20  0.4      48   #facet 4
   47        0.3   20  0.6      32   #facet 5

If I added to gggplot +geom_hline(yintercept=D$expected) I get all the lines on each facet... How can I have only one line on each facet?

dww
  • 30,425
  • 5
  • 68
  • 111
AWRAM
  • 333
  • 2
  • 16

0 Answers0