- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if a vector contains a given value in R?
We can use match %in% to check whether a vector contains a given value of not
Example
> x <-c(1,10, 99, 1024) > 1%in%x [1] TRUE > 10%in%x [1] TRUE > 99%in%x [1] TRUE > 1024%in%x [1] TRUE > 100%in%x [1] FALSE
We can also do this for checking the common values between two vectors.
Example
> x <-c(1,10, 99, 1024) > y<-c(2,10, 133, 1000) > x%in%y [1] FALSE TRUE FALSE FALSE
- Related Articles
- How to check whether a vector contains an NA value or not in R?
- Java Program to Check if An Array Contains a Given Value
- Golang Program to Check if An Array Contains a Given Value
- Haskell Program to Check if An Array Contains a Given Value
- How to check if a vector exists in a list in R?
- How to find unique permutations if a vector contains repeated elements in R?
- How to check if a Perl array contains a particular value?
- How to check which list element contains a particular value in R?
- How to find the cumulative sums if a vector contains NA values in R?
- Check if any value in an R vector is greater than or less than a certain value.
- How to check if a data frame column contains duplicate values in R?
- Java Program to Check if An Array Contains the Given Value
- How to replace a value in an R vector?
- How to check if a given directory contains any other directory in Python?
- How to check if all values in a vector are integer or not in R?

Advertisements