Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Without the regexpr() and gregexpr() functions, write a function called my_gregexpr() that inputs a character string pattern and a character vector text and returns a
Without the regexpr() and gregexpr() functions, write a function called my_gregexpr() that inputs a character string pattern and a character vector text and returns a list of the same length as text, each component of which is an integer vector giving the starting positions of every (disjoint) match of pattern in the corresponding entry in text or -1 if there is no match. The output values from my_gregexpr(pattern, text) and gregexpr(pattern, text) should be identical for any character string pattern and character vector text. Hint: Your my_gregexpr() function only needs to account for literal patterns, i.e., it does not need to work for regular expressions. Note: You do not need to add attributes to each component of the output list of my_gregexpr() to match gregexpr(). This will mean identical(my_gregexpr(pattern, text), gregexpr(pattern, text)) will always return FALSE
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started