

Hi,
I need some neat ways of determing a subset of binary strings. For example,
x=c(0,0,1), y=c(0,1,1), z=c(0,1,0). So x is a subset of y and z is also a
subset of y, but x is not a subset of z.
I tried to search R functions and packages but no hits. Any ideas?
Best,
Jing

Jing Tang, PhD
Senior Researcher
Finnish Institute of Molecular Medicine (FIMM)
FI00014 University of Helsinki
Finland
[[alternative HTML version deleted]]
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On 20022012, at 14:15, jing tang wrote:
> Hi,
>
> I need some neat ways of determing a subset of binary strings. For example,
> x=c(0,0,1), y=c(0,1,1), z=c(0,1,0). So x is a subset of y and z is also a
> subset of y, but x is not a subset of z.
>
> I tried to search R functions and packages but no hits. Any ideas?
x < c(0,0,1)
y < c(0,1,1)
z < c(0,1,0)
any(x & y)
any(z & y)
any(x & z)
Berend
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


Hi Jing,
I am not sure I got your definition of a "subset" right, but maybe this
helps.
Regards,
Enrico
x < c(0,0,1)
y < c(0,1,1)
z < c(0,1,0)
## is x a 'subset' of y?
isSubset < function(x, y) {
x < as.logical(x)
y < as.logical(y)
all(y[x] == TRUE)
}
isSubset(x, y)
isSubset(z, y)
isSubset(x, z)
## create all subsets
exampleVec < c(0,1,1,0,1)
fun < function(t)
if (t) 0:1 else 0
expand.grid(lapply(as.list(exampleVec), fun))
Am 20.02.2012 14:15, schrieb jing tang:
> Hi,
>
> I need some neat ways of determing a subset of binary strings. For example,
> x=c(0,0,1), y=c(0,1,1), z=c(0,1,0). So x is a subset of y and z is also a
> subset of y, but x is not a subset of z.
>
> I tried to search R functions and packages but no hits. Any ideas?
>
>
>
> Best,
>
> Jing
>
>
>
> 
>
> Jing Tang, PhD
>
> Senior Researcher
>
> Finnish Institute of Molecular Medicine (FIMM)
>
> FI00014 University of Helsinki
>
> Finland
>
>
>
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/rhelp> PLEASE do read the posting guide http://www.Rproject.org/postingguide.html> and provide commented, minimal, selfcontained, reproducible code.
>

Enrico Schumann
Lucerne, Switzerland
http://nmof.net/______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.


On Mon, Feb 20, 2012 at 03:15:53PM +0200, jing tang wrote:
> Hi,
>
> I need some neat ways of determing a subset of binary strings. For example,
> x=c(0,0,1), y=c(0,1,1), z=c(0,1,0). So x is a subset of y and z is also a
> subset of y, but x is not a subset of z.
>
> I tried to search R functions and packages but no hits. Any ideas?
Hi.
Try this
all(x <= y) # [1] TRUE
all(z <= y) # [1] TRUE
all(x <= z) # [1] FALSE
Hope this helps.
Petr Savicky.
______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/rhelpPLEASE do read the posting guide http://www.Rproject.org/postingguide.htmland provide commented, minimal, selfcontained, reproducible code.

