Hello Experts,

I found this example on web and use it just for explanation.
(  
http://stackoverflow.com/questions/15867263/ggplot2-geom-text-with-facet-grid  )
                                                                       
 library(ggplot2)                                                      
 x <-runif(9, 0, 125)                                                  
 data <- as.data.frame(x)                                              
 data$y <--runif(9, 0, 125)                                            
 data$yy <- factor(c("a","b","c"))                                     
                                                                       
 ggplot(data, aes(x, y)) + geom_point(shape = 2) + facet_grid(~yy) + 
     geom_text(aes(x, y, label=lab),                                 
         data=data.frame(x=60,y=Inf,lab=c("this","is","the way"),
             yy=letters[1:3]), vjust=1)                            
                                                                       
                                                                       
 Running it you will see the text "this","is","the way" distributed in each 
facet.
                                                                       
 In my case I would like to show a e.g the max(y) .                    
 I modified the ggplot statement like this:                            
                                                                       
                                                                       
 ggplot(data, aes(x, y )) + geom_point(shape = 2 ) + facet_grid(~yy) +
     geom_text(aes(x, y, , yy , label=lab),                          
                  
data=data.frame(x=60,y=Inf,lab=c(as.character(max(x)),"is","the way"),
 yy=letters[1:3]),                                                   
                  vjust=1 )                                                     
  
                                                                       
 BUT, the result is the max(x) of ALL rows in the data frame.          
 What I need is to find the max value just for the points in each of the facets.
 AND I need it with facet_wrap if possible.                            
                                                                       
 I did not find any way to get access to the current yy value.         
                                                                       
 Hope someone can help                                                 
                                                                       
 R. Kemper                                                             
                                                                       
                                                                       
                                                                       
                                                                       
                                                                       




Rolf  Kemper, Manager, Mixed Signal Design, Networking, Renesas Electronics 
Europe GmbH, , Arcadiastr. 10, 40472, Duesseldorf, Germany,  Phone:+49 211
6503-1475, Fax:+49 211 6503-1540, mailto:rolf.kem...@renesas.com, 
http://www.renesas.eu

This message is intended only for the use of the address...{{dropped:24}}

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to