Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Get the elements in a vector that are not repeated a specified number of times

I have a vector that looks like this:

v <- c(1,2,2,3,3,3,4,4)

How can I get the elements that are not repeated twice? In other words, they are only present once or more than twice in the vector.

Thank you!

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try subset with ave

> subset(v, ave(v, v, FUN = length) != 2)
[1] 1 3 3 3
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading