On Nov 18, 2010, at 10:42 AM, Martin Tomko wrote:

Thanks Steve, that explains it... Unfortunately, I did nto get that from my R docs...

I am still searching for a solution for matching the entries in my matrix by matching the rownames to the entires in a subset I got using Gerrit's method.

OK. Looking back at your original question it appears you are confusing the actions of "&" and "|" when setting up selection criteria. It may sound strange but if you want the union of the group that is A and the group the is B then the criteria needs to be A | B , not A & B.


So your original operation should have been:

subset1<-subset1[ subset1$Class == 1 | subset1$Type == 1 | subset1$Category == 1, ]

--
David.


Any idea?
Thanks
Martin

On 11/18/2010 4:35 PM, Steve Lianoglou wrote:
Hi,

On Thu, Nov 18, 2010 at 10:25 AM, Martin Tomko<martin.to...@geo.uzh.ch > wrote:

Hi Gerrit,
indeed, that works. Excellent tip!

For reference, I did this:

subset1<-subset(summarystats,(Type==1)&(Class==1)&(Category==1))

I am still not totally sure when one uses "&" amd when"&&" - I was under
the impression that&&  stands for logical AND....

If you can't find the appropriate documentation, try to experiment in
your workspace:

R>  c(TRUE, TRUE, FALSE, TRUE)&  c(FALSE, TRUE, TRUE, TRUE)
[1] FALSE  TRUE FALSE  TRUE

R>  c(TRUE, TRUE, FALSE, TRUE)&&  c(FALSE, TRUE, TRUE, TRUE)
[1] FALSE

The single logical operators (&  , |) run over the entire length of
your logical vectors.
The doubles (&&, ||) just evaluate the first element of the vectors,
and ignore the rest.



______________________________________________
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.

David Winsemius, MD
West Hartford, CT

______________________________________________
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.

Reply via email to