Hi Gerrit,

Thanks for your advice.


In;

2.4 Logical vectors
http://cran.r-project.org/doc/manuals/R-intro.html#R-and-statistics

It states:-

The logical operators are <, <=, >, >=, == for exact equality and != for 
inequality ........

>    # exact equality
!=   # inequality


I did follows;

> x <- 1:5
> x
[1] 1 2 3 4 5

> temp <- x != 1
> temp
[1] FALSE  TRUE  TRUE  TRUE  TRUE

That is correct.


> rm(temp)
> 
> temp <- x > 1
> temp
[1] FALSE  TRUE  TRUE  TRUE  TRUE

That seems not correct.

My understanding is;
> [1] TRUE  FALSE  FALSE FALSE  FALSE

B.R.
Stephen L





----- Original Message ----
From: Gerrit Eichner <[email protected]>
To: Stephen Liu <[email protected]>
Cc: [email protected]
Sent: Thu, November 4, 2010 2:34:55 PM
Subject: Re: [R] Logical vectors

On Wed, 3 Nov 2010, Stephen Liu wrote:

[snip]

> 2)
>> x
> [1] 1 2 3 4 5
>> temp <- x > 1
>> temp
> [1] FALSE  TRUE  TRUE  TRUE  TRUE
>
>
> Why NOT
>> temp
> [1] TRUE  FALSE  FALSE FALSE  FALSE
>
> ?


Maybe because of the definition of ">" (greater (!) than)? Or do you 
expect 1 to be greater than 1 and not greater than 2, 3, 4, and 5?

  Regards  --  Gerrit

---------------------------------------------------------------------
AOR Dr. Gerrit Eichner               Mathematical Institute, Room 212
[email protected]   Justus-Liebig-University Giessen
Tel: +49-(0)641-99-32104          Arndtstr. 2, 35392 Giessen, Germany
Fax: +49-(0)641-99-32109        http://www.uni-giessen.de/cms/eichner
---------------------------------------------------------------------




______________________________________________
[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
and provide commented, minimal, self-contained, reproducible code.

Reply via email to