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
10 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
• 26,020 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
191 views
+1 vote
2 answers

Custom Function to replace missing values in a vector with the mean of values

Try this. lapply(a,function(x){ifelse(is.na(x),mean(a,na.rm = TRUE) ...READ MORE

answered Aug 14 in Data Analytics by anonymous
76 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,700 points
98 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,700 points
118 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,700 points
76 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,700 points
70 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
• 26,020 points
100 views
0 votes
2 answers

How can we count TRUE values in a logical vector?

Hi, You can get a count of all ...READ MORE

answered Aug 20 in Data Analytics by anonymous
• 26,020 points
1,517 views