Re: [R] Is there a convenient function that can check if a vector is a subset of another one?

From: Pierre Kleiber <pkleiber_at_honlab.nmfs.hawaii.edu>
Date: Wed 30 Mar 2005 - 10:37:47 EST

all(x %in% y) should do what you want:

 > x <- 2:5
 > y <- 1:10
 > all(x %in% y)

[1] TRUE
 > all(y %in% x)
[1] FALSE
 >

Cheers, Pierre

Terry Mu wrote:
> x <- 2:5
> y <- 1:10
>
> Is there something like:
>
> is.subset(x, y) == T
>
> Thank you,
>
> ______________________________________________
> R-help@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>

-- 
-----------------------------------------------------------------
Pierre Kleiber, Ph.D       Email: pkleiber@honlab.nmfs.hawaii.edu
Fishery Biologist            Tel: 808 983-5399 / (hm)808 737-7544
NOAA Fisheries Service - Honolulu Laboratory    Fax: 808 983-2902
2570 Dole St., Honolulu, HI 96822-2396
-----------------------------------------------------------------
  "God could have told Moses about galaxies and mitochondria and
   all.  But behold... It was good enough for government work."

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
Received on Wed Mar 30 10:45:13 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:30:57 EST