Christophe Genolini
2014-Mar-21 00:02 UTC
[Rd] Memcheck: error in a switch using getGraphicsEvent
Hi the list, One of my package has an (other) error detected by memtest that I do not manage to understand. Here is the message that I get from Memtest --- 8< ---------------- > try(choice(cld1)) Error in switch(EXPR = choix, Up = { : EXPR must be a length 1 vector --- 8< ---------------- The choice function does call the choiceChangeParam function, which is: --- 8< ---------------- choiceChangeParam <- function(paramChoice){ texte <- paste(" ~ Choice : menu ~\n",sep="") choix <- getGraphicsEvent(texte,onKeybd=function(key){return(key)}) switch(EXPR=choix, "Up" = { if(xy[1]>1){ paramChoice['toDo'] <- "xy" xy[2]<-1 xy[1]<-xy[1]-1 paramChoice['xy']<-xy }else{paramChoice['toDo'] <- ""} }, "Down" = { if(xy[1]<nrow(paramChoice['critMatrix'])){ paramChoice['toDo'] <- "xy" xy[2]<-1 xy[1]<-xy[1]+1 paramChoice['xy']<-xy "d" = { paramChoice['toDo'] <- "changeCriterion" paramChoice['critRank'] <- (paramChoice['critRank']%%length(CRITERION_NAMES)) + 1 }, "c" = { paramChoice['toDo'] <- "order" }, default={} ) return(paramChoice) } --- 8< ---------------- choix is a character of lenght 1 since getGraphicsEvent return a character, am I wrong? -- Christophe Genolini Ma?tre de conf?rences en bio-statistique Universit? Paris Ouest Nanterre La D?fense INSERM UMR 1027
Duncan Murdoch
2014-Mar-21 00:45 UTC
[Rd] Memcheck: error in a switch using getGraphicsEvent
On 2014-03-20, 8:02 PM, Christophe Genolini wrote:> Hi the list, > > One of my package has an (other) error detected by memtest that I do not manage to understand. > Here is the message that I get from Memtest > > --- 8< ---------------- > > try(choice(cld1)) > Error in switch(EXPR = choix, Up = { : EXPR must be a length 1 vector > --- 8< ---------------- > > The choice function does call the choiceChangeParam function, which is: > > --- 8< ---------------- > choiceChangeParam <- function(paramChoice){ > > texte <- paste(" ~ Choice : menu ~\n",sep="") > > choix <- getGraphicsEvent(texte,onKeybd=function(key){return(key)}) > switch(EXPR=choix, > "Up" = { > if(xy[1]>1){ > paramChoice['toDo'] <- "xy" > xy[2]<-1 > xy[1]<-xy[1]-1 > paramChoice['xy']<-xy > }else{paramChoice['toDo'] <- ""} > }, > "Down" = { > if(xy[1]<nrow(paramChoice['critMatrix'])){ > paramChoice['toDo'] <- "xy" > xy[2]<-1 > xy[1]<-xy[1]+1 > paramChoice['xy']<-xy > "d" = { > paramChoice['toDo'] <- "changeCriterion" > paramChoice['critRank'] <- (paramChoice['critRank']%%length(CRITERION_NAMES)) + 1 > }, > "c" = { > paramChoice['toDo'] <- "order" > }, > default={} > > ) > return(paramChoice) > } > --- 8< ---------------- > > choix is a character of lenght 1 since getGraphicsEvent return a character, am I wrong? >It can also return NULL, but to be sure, why not print the value? Duncan Murdoch