Try this:

m <- match(4, c(1,2,3))
ifelse(is.na(m), stop("Not Found"), m)

Or:

stopifnot(!is.na(m))

On Sat, Aug 22, 2009 at 9:36 PM, Peng Yu <pengyu.ut@gmail.com> wrote:

> Hi,
>
> > match(4, c(1,2,3))
> [1] NA
>
> The above code run smoothly. It would not stop when 4 does not mach in
> c(1,2,3). I am wondering if there is a way to stop the code and pop up
> an error message immediately. This capability to stop will make
> debugging easier.
>
> Regards,
> Peng
>
> ______________________________________________
> R-help@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
Henrique Dallazuanna
Curitiba-Paraná-Brasil
25° 25' 40" S 49° 16' 22" O

	[[alternative HTML version deleted]]


