[R] list(0) to integer
tobias.verbeke at telenet.be
Mon Dec 27 14:23:25 CET 2004
On Mon, 27 Dec 2004 03:18:53 -0800 (PST)
Frederic renaud <fren2 at yahoo.com> wrote:
> 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 :
> cat("Effectif des populations (integer):")
> if (is.integer(n[])==TRUE) break
> print("L'effectif des population doit etre un
if (!is.integer(unlist(n))) stop("L'effectif ...")
You don't need `== TRUE' (and I guess you meant `== FALSE')
An error action can be executed using stop("some error message").
`break' breaks out of the loop (ie goes to the first statement
after the loop), so the print statement cannot be executed.
Are you sure you need n to be a list ?
> That doesn't work of course but I've no idea to do
> this. How verify that n[] is an integer an
> transform them as an integer (as.integer(n) doesn't
> Someone can help me? Thanks!
> R-help at stat.math.ethz.ch mailing list
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
More information about the R-help