[R] Compare similarit of two vector of not same length

Berend Hasselman bhh at xs4all.nl
Sat Mar 24 16:08:49 CET 2012


On 24-03-2012, at 12:44, Alaios wrote:

> Dear all,
> this is not strictly R question. I have two vectors of different length (this is in the order of 10%). I am trying to see if still one can compare these two for similarity.
> 

What do you mean?

- all entries in shorter vector occur in longer vector
- the shorter vector is a sequence within the longer vector

In the first case you could use %in% and all()
In the second case see this discussion:

http://r.789695.n4.nabble.com/matching-a-sequence-in-a-vector-td4389523.html
https://stat.ethz.ch/pipermail/r-help/2012-February/303608.html

Berend


> IF the vectors were of the same length I would just take the difference of the two and plot a pdf of it.
> 
> One way I am thinking is prorbably to find the longer length and short it in some way to get to the length of the short. 
> 
> 
> Which are the math formulations for this type of problems and which of those R supports?
> 
> Regards
> Alex
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-help at 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.



More information about the R-help mailing list