I've been searching for a way to ask grep to return a whole line for a matching pattern. Is there functionality for this in R's grep()? I am imagining something like the unix grep arguments -An
Some context: For a paper I've written I want to create a data table or a vector of all citations in a paper. Extracting everything in the paper thats within parentheses using qdapRegex::rm_round()
sometimes only returns a year (in the case of citations written like: 'As put forth by Smith (2020)'). It would be nice to grab the whole sentence instead of just '2020'.
Any thoughts? Thank you!