Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
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
Advertisements
