To match a string with some parameters, the grep() function is used. The grep() function returns the index at which the pattern is found in the string. It also tells us the location of the specified string in the vector.

Example:

Find all the instances of 'he' in the string.

str <- c("Hello", "hello", “human”, "hi", "hey")
grep('he', str)

Output

[1] 1 2 5

Note: R allows various integration with its procedures written in the C, C++, .Net, Python, or the FORTRAN languages for efficiency. Read answers to the r coding interview questions carefully to understand the subject and get that dream job.

BY Best Interview Question ON 18 Jul 2020