R/genAskForYN.R

Defines functions genAskForYN

genAskForYN<-function(question,cont=0,n.attempts=5,omit.question=FALSE){
  str = tolower(readline(question))
  if(omit.question){return(TRUE)}
  if(cont<n.attempts){
    switch(str,
           y={
             return(TRUE)
           },
           yes={
             return(TRUE)
           },
           n={
             return(FALSE)
           },
           no={
             return(FALSE)
           },
           {
             return(genAskForYN(question,cont+1))
           }
    )
  }else{
    message("No answering question, stoping process...")
  }
}

Try the RGISTools package in your browser

Any scripts or data that you put into this service are public.

RGISTools documentation built on July 2, 2020, 3:58 a.m.