Re-Hello frederic,

Don't worry, i have the same english speaking problem, here is what i suggest :

n <- natScan()

natScan <- function(){
 cat("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n")
 cat("Give me a natural (everything after the '.' will be ignored)\n")
 n <- scan("", character(), 1,quiet=T)
 n  <- as.integer(n)
 if(length(n)==0||is.na(n)){
    cat("!! that's not what i want !!\n")
    return(natScan())
 }
 return(n)
}

Hope this helps


Frederic renaud a �crit :

Because if the user write something else (a real or a
character), the program stop. I want in this case (if
the user don't write a natural) that the program write
again :" A natural, please!"
I've some difficult to speak english! Do you
understand?
Thanks
Fred


--- Romain Fran�ois <[EMAIL PROTECTED]> wrote:



Hello frederic,

why don't you just try something like :

n <- scan("", integer(), 1)


You may also need to take a look there : http://zoonek2.free.fr/UNIX/48_R/all.html
and maybe there http://addictedtor.free.fr (for the
moment there is noting usefull there but soon ....)



Frederic renaud a �crit :



Hello
I've another question :-)
I would like to transform a list to a integer.
I must be sure that the number entered by the user


is


an integer! Thus, I've made :


repeat{ cat("Effectif des populations (integer):") n<-scan("",n=1,what=list(0),quiet=TRUE)

if (is.integer(n[[1]])==TRUE) break
print("L'effectif des population doit etre un
entier")
}

That doesn't work of course but I've no idea to do
this. How verify that n[[1]] is an integer an
transform them as an integer (as.integer(n) doesn't
work!) Someone can help me? Thanks!
Fred

_


--
Romain FRANCOIS : [EMAIL PROTECTED]
page web : http://addictedtor.free.fr/  (en construction)
06 18 39 14 69 / 01 46 80 65 60
_______________________________________________________
Etudiant en 3eme ann�e
Institut de Statistique de l'Universit� de Paris (ISUP)
Fili�re Industrie et Services
http://www.isup.cicrp.jussieu.fr/

______________________________________________
[email protected] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html

Reply via email to