[R] getGraphicsEvent plotting two graph

cgenolin at u-paris10.fr cgenolin at u-paris10.fr
Sun Apr 13 14:48:35 CEST 2008


Hi the list,

I need to use getGraphicsEvent to plot two graph. On the following toy 
example:
- the function b is ploting two graph depending on a parameter
- the function a is calling b according to some user answers. It is 
suppose to call b until the user press Return, but it does not.


b <- function(x){
    dev.off(2);dev.off(3)
    windows();windows(3,3,xpos=0)
    dev.set(2);plot(1:x)
    dev.set(3);plot(1:x^2)
    return(NULL)
}
b(2)

a <- function(y){
    b(y)
    getGraphicsEvent("Arrow Up or Return",
        onKeybd=function(key){
            if(key!="ctrl-J"){
                if(key=="Up"){y <<- y+1}else{}
                b(y)
                cat("\n*** This function a never gets here... ***\n")
                return(NULL)
            }else{
                return(TRUE)
            }
        }
    )
}

a(3)

Is there something wrong in my code, or something I did not understand 
in getGraphicsEvent ?
I try on R 2.2.1, then on R 2.7

Thanks for your help.

Christophe

----------------------------------------------------------------
Ce message a ete envoye par IMP, grace a l'Universite Paris 10 Nanterre



More information about the R-help mailing list