Hi krishna,
1.How can we compare these two vectors,whether each element is exactly
matched with the elements in the other vector?
x=c(5, 8, 28, 29, 30)
y=c(5, 8, 28, 29, 31)
z<-(x %in% y)
> z
[1] TRUE TRUE TRUE TRUE FALSE
(OR)
z<-identical(x,y)
> z
[1] FALSE
(OR) to get values that are ma
> x=c(5, 8, 28, 29, 30)
> y=c(5, 8, 28, 29, 31)
> x==y
[1] TRUE TRUE TRUE TRUE FALSE
> which(x==y)
[1] 1 2 3 4
> which(x!=y)
[1] 5
> x[x!=y]
[1] 30
> y[x!=y]
[1] 31
RTFM! - just kidding ;)
also, this might not work for floating point numbers, theres a section in the
documentation/fa
Either == or %in% if you care about order or not.
Michael
On Aug 8, 2012, at 7:00 AM, Sri krishna Devarayalu Balanagu
wrote:
> x=c(5, 8, 28, 29, 30)
> y=c(5, 8, 28, 29, 31)
> How can we compare these two vectors, whether each element is exactly matched
> with the elements in the other vector
x=c(5, 8, 28, 29, 30)
y=c(5, 8, 28, 29, 31)
How can we compare these two vectors, whether each element is exactly matched
with the elements in the other vector ?
How can we get the non matched elements from both the vectors?
Can anyone help?
Notice: The information
4 matches
Mail list logo