have a look at function all() but also at function all.equal() -- for
your example,
x1 <- c(1,2,3)
x2 <- c(1,2,3)
x3 <- c(1,2,5)
all(x1 == x2)
all(x1 == x3)
# this safer
isTRUE(all.equal(x1, x2))
isTRUE(all.equal(x1, x3))
I hope it helps.
Best,
Dimitris
On 8/13/2010 8:49 PM, Downey, Patri
all(c(1, 2, 3) %in% c(1,2,3))
On Fri, Aug 13, 2010 at 3:49 PM, Downey, Patrick wrote:
> Hello,
>
> Is there a way to get a single TRUE or FALSE statement from comparing two
> vectors? For example,
> c(1,2,3) == c(1,2,3)
> produces
> TRUE TRUE TRUE
>
> where I would like it to produce only
> TRUE
49 PM
> To: r-help@r-project.org
> Subject: [R] Equality of Vectors
>
> Hello,
>
> Is there a way to get a single TRUE or FALSE statement from comparing
> two
> vectors? For example,
> c(1,2,3) == c(1,2,3)
> produces
> TRUE TRUE TRUE
>
> where I would li
Hi Mitch,
How about identical()?
> identical(c(1,2,3), c(1,2,5))
[1] FALSE
> identical(c(1,2,3), c(1,2,3))
[1] TRUE
See ?identical and ?all.equal for more information.
HTH,
Jorge
On Fri, Aug 13, 2010 at 2:49 PM, Downey, Patrick <> wrote:
> Hello,
>
> Is there a way to get a single TRUE or FA
?all
- Phil Spector
Statistical Computing Facility
Department of Statistics
UC Berkeley
spec.
?all
nikhil.l...@gmail.com
On Aug 13, 2010, at 2:49 PM, Downey, Patrick wrote:
c(1,2,3) == c(1,2,3)
__
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
Hello,
Is there a way to get a single TRUE or FALSE statement from comparing two
vectors? For example,
c(1,2,3) == c(1,2,3)
produces
TRUE TRUE TRUE
where I would like it to produce only
TRUE
for use in an if statement.
Likewise, when two vectors are not exactly identical (in all elements) I
w
7 matches
Mail list logo