  Hi!

Maybe something like this:

x <- 2
y <- 3
#since FALSE will be converted to 0 and TRUE to 1 you can do
as.numeric(x>y)
as.numeric(x<y)

HTH
Ivan

Le 9/3/2010 15:33, Hyunchul Kim a écrit :
> Hi, all
>
> is there a built-in function to compare two numbers?
>
> something like following function
>
> cmp<- function(x, y){
>      value<- 0
>      if (x>  y){
>          value<- 1
>      }else if (x == y){
>          value<- 0
>      }else {
>          value<- -1
>      }
>      return(value)
> }
>
> Thanks in advance,
>
> Hyunchul
>
> 	[[alternative HTML version deleted]]
>
> ______________________________________________
> 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.
>

-- 
Ivan CALANDRA
PhD Student
University of Hamburg
Biozentrum Grindel und Zoologisches Museum
Abt. Säugetiere
Martin-Luther-King-Platz 3
D-20146 Hamburg, GERMANY
+49(0)40 42838 6231
ivan.calandra@uni-hamburg.de

**********
http://www.for771.uni-bonn.de
http://webapp5.rrz.uni-hamburg.de/mammals/eng/mitarbeiter.php


	[[alternative HTML version deleted]]

