Question

How are regexpr, gregexpr and regexec different than grep/grepl?

How are regexpr, gregexpr and regexec different than grep/grepl?

Homework Answers

Answer #1

grep(), grepl(): These functions search for matches of a regular expression/pattern in a character vector. grep() returns the indices into the character vector that contain a match or the specific strings that happen to have the match. grepl() returns a TRUE/FALSE vector indicating which elements of the character vector contain a match.

regexpr(), gregexpr(): Search a character vector for regular expression matches and return the indices of the string where the match begins and the length of the match

regexec(): This function searches a character vector for a regular expression, much like regexpr(), but it will additionally return the locations of any parenthesized sub-expressions.

please rate my answer and comment for doubts.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
How is a Chromoplast different than a Chlorplast?
How is a Chromoplast different than a Chlorplast?
Chapter 8: Searching, Extracting, and Archiving Data Exercise 8.a: Using grep, find, and regular expressions (Objective...
Chapter 8: Searching, Extracting, and Archiving Data Exercise 8.a: Using grep, find, and regular expressions (Objective 3.2) Linux Distribution: Fedora (non-root user & password needed) Desktop Environment: GNOME 3 1.   If you have not already done so, boot up your computer (or virtual machine) to start the Fedora Linux distribution. 2.   When the machine has booted up, access the tty2 virtual terminal by pressing Ctrl+Alt+F2. 3.   Log on to a regular user’s account by typing in the username at the...
How are odors different than other stimuli?
How are odors different than other stimuli?
1. How is capitalism different than mercantilism?
1. How is capitalism different than mercantilism?
Write a regular expression with the grep command, which marks only and all underline parts, for...
Write a regular expression with the grep command, which marks only and all underline parts, for the sentences listed below: (the file containing these sentences is called “Q1.txt”) I want to pass the exam. Is the PowerPoint file ready? This is the moment to pay the bill. Write a regular expression with the grep command, which marks only and all underline parts, for the sentences listed below: (the file containing these sentences is called “Q1.txt”) I want to pass the...
How is apparent magnitude different than absolute magnitude?
How is apparent magnitude different than absolute magnitude?
What does the following script do? #!/bin/bash echo $(ls|grep -E "*\.$1$"|wc -l)
What does the following script do? #!/bin/bash echo $(ls|grep -E "*\.$1$"|wc -l)
How is calculating a confidence interval similar to or different than gambling?
How is calculating a confidence interval similar to or different than gambling?
How is transduction in photoreceptors different than other types of receptors?
How is transduction in photoreceptors different than other types of receptors?
How is performability different than reliability measure for a computer system?
How is performability different than reliability measure for a computer system?
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT