Search elements in a vector or list

0 votes
How to search elements in a vector or list?
What are the possible means of finding position of element in the list?
Aug 21 in Data Analytics by kaushik
12 views

1 answer to this question.

0 votes

There are multiple functions and operators that can be used to search elements in list or vector.

A few of them are,

1. %in%  - returns TRUE/FALSE based on whether the element is found or not found.

Syntax: v1 %in% v2

2.  match()  - similar to %in% but in the form of a function. Match() returns a vector of the positions of (first) matches of its first argument in its second. 

Syntax: 

match(x, table, nomatch = NA_integer_, incomparables = NULL)

3.  is.element - is.element(x, y) is identical to x %in% y. 

syntax: 

is.element(x, y)
answered Aug 21 by Cherukuri
• 31,840 points

Related Questions In Data Analytics

0 votes
1 answer
0 votes
1 answer

Finding the nth highest value in a vector or a data-frame column

sort(x,T)[n] Here, 'x' is the data-frame/vector and 'n' ...READ MORE

answered May 31, 2018 in Data Analytics by Bharani
• 4,550 points
356 views
0 votes
1 answer

How to add elements into a list in R?

hey, Add elements into list as below. list = ...READ MORE

answered Sep 30 in Data Analytics by anonymous
• 31,840 points
20 views
0 votes
1 answer

By using dpylr package sum of multiple columns

Basically here we are making an equation ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
112 views
0 votes
1 answer

How to convert a text mining termDocumentMatrix into excel or csv in R?

By assuming that all the values are ...READ MORE

answered Apr 5, 2018 in Data Analytics by DeepCoder786
• 1,720 points
156 views
0 votes
1 answer

In a dpylr pipline how to use sample and seq?

For avoiding rowwise(), I prefer to use ...READ MORE

answered Apr 6, 2018 in Data Analytics by DeepCoder786
• 1,720 points
82 views
0 votes
1 answer

How to create a list of Data frames?

Basically all we have to do is ...READ MORE

answered Apr 9, 2018 in Data Analytics by DeepCoder786
• 1,720 points
98 views
0 votes
1 answer

reverse a list or vector in R

@ch, Use rev function to reverse R objects ...READ MORE

answered Oct 14 in Data Analytics by Cherukuri
• 31,840 points
18 views
0 votes
2 answers

How to count the number of elements with the values in a vector?

Use dplyr function group_by(). > n = as.data.frame(num) > ...READ MORE

answered Aug 21 in Data Analytics by anonymous
• 31,840 points
129 views