[R] odd subset behavior
Joshua Wiley
jwiley.psych at gmail.com
Sun Aug 29 04:54:25 CEST 2010
Dear Erin,
-0.50 is greater than -1.00, this means that your logical test returns
all FALSE answers. Now consider the results of:
x[FALSE]
you are selecting none of 'x', hence numeric(0).
Perhaps you mean:
x[x <= -0.50 & x >= -1.0]
HTH,
Josh
On Sat, Aug 28, 2010 at 7:47 PM, Erin Hodgess <erinm.hodgess at gmail.com> wrote:
> Dear R People:
>
> I just produced the following:
>
> x <- seq(-3,3,.01)
> x[x>= -0.50 & x<= -1.0]
> numeric(0)
> x[x>= -0.50 && x<= -1.0]
> numeric(0)
>
> What am I doing wrong, please? This seems strange.
>
> Thanks,
> Erin
>
>
> --
> Erin Hodgess
> Associate Professor
> Department of Computer and Mathematical Sciences
> University of Houston - Downtown
> mailto: erinm.hodgess at gmail.com
>
> ______________________________________________
> 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.
>
--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://www.joshuawiley.com/
More information about the R-help
mailing list