[R] About basic logical operators

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Wed Mar 6 03:18:24 CET 2013


faq 7.31
---------------------------------------------------------------------------
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
--------------------------------------------------------------------------- 
Sent from my phone. Please excuse my brevity.

Victor hyk <victor_hyk at yahoo.ca> wrote:

>Hello everyone,
>��������� I have a basic question regarding logical operators.
>> x<-seq(-1,1,by=0.02)
>> x
>� [1] -1.00 -0.98 -0.96 -0.94 -0.92 -0.90 -0.88 -0.86 -0.84 -0.82 -0.80
>-0.78
>�[13] -0.76 -0.74 -0.72 -0.70 -0.68 -0.66 -0.64 -0.62 -0.60 -0.58 -0.56
>-0.54
>�[25] -0.52 -0.50 -0.48 -0.46 -0.44 -0.42 -0.40 -0.38 -0.36 -0.34 -0.32
>-0.30
>�[37] -0.28 -0.26 -0.24 -0.22 -0.20 -0.18 -0.16 -0.14 -0.12 -0.10 -0.08
>-0.06
>�[49] -0.04 -0.02� 0.00� 0.02� 0.04� 0.06� 0.08� 0.10� 0.12� 0.14�
>0.16� 0.18
>�[61]� 0.20� 0.22� 0.24� 0.26� 0.28� 0.30� 0.32� 0.34� 0.36� 0.38�
>0.40� 0.42
>�[73]� 0.44� 0.46� 0.48� 0.50� 0.52� 0.54� 0.56� 0.58� 0.60� 0.62�
>0.64� 0.66
>�[85]� 0.68� 0.70� 0.72� 0.74� 0.76� 0.78� 0.80� 0.82� 0.84� 0.86�
>0.88� 0.90
>�[97]� 0.92� 0.94� 0.96� 0.98� 1.00
>> x[x<=0.02]
>�[1] -1.00 -0.98 -0.96 -0.94 -0.92 -0.90 -0.88 -0.86 -0.84 -0.82 -0.80
>-0.78
>[13] -0.76 -0.74 -0.72 -0.70 -0.68 -0.66 -0.64 -0.62 -0.60 -0.58 -0.56
>-0.54
>[25] -0.52 -0.50 -0.48 -0.46 -0.44 -0.42 -0.40 -0.38 -0.36 -0.34 -0.32
>-0.30
>[37] -0.28 -0.26 -0.24 -0.22 -0.20 -0.18 -0.16 -0.14 -0.12 -0.10 -0.08
>-0.06
>[49] -0.04 -0.02� 0.00
>> x[x<0.2]
>�[1] -1.00 -0.98 -0.96 -0.94 -0.92 -0.90 -0.88 -0.86 -0.84 -0.82 -0.80
>-0.78
>[13] -0.76 -0.74 -0.72 -0.70 -0.68 -0.66 -0.64 -0.62 -0.60 -0.58 -0.56
>-0.54
>[25] -0.52 -0.50 -0.48 -0.46 -0.44 -0.42 -0.40 -0.38 -0.36 -0.34 -0.32
>-0.30
>[37] -0.28 -0.26 -0.24 -0.22 -0.20 -0.18 -0.16 -0.14 -0.12 -0.10 -0.08
>-0.06
>[49] -0.04 -0.02� 0.00� 0.02� 0.04� 0.06� 0.08� 0.10� 0.12� 0.14� 0.16�
>0.18
>[61]� 0.20
>> 
>���� Why does "x[x<=0.02]" return� no 0.02 but "x[x<0.2]" return a
>subsample with 0.02?
>���� Anyone who can tell me why?
>���� Thanks!
>
>���� Victor
>
>	[[alternative HTML version deleted]]
>
>
>
>------------------------------------------------------------------------
>
>______________________________________________
>R-help at 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.



More information about the R-help mailing list