In R, is it possible to extract group capture from a regular expression match? As far as I can tell, none of grep , grepl , regexpr , gregexpr , sub , or gsub return the group captures.
In the data frame below, I want to create a new column or a new data frame such that A1 and B1 are subgroups. for example, A1 would have REF, FOW and NIGHT as it's element and B2 would have NURT, PEGGY and PILLAR. Is there a package that can do that?
I am sorry, I do not understand how you want to transform the data frame. However, you can use group captures with regex in R. Here is a simple example with sub() where text that starts with three digits, then has non-digits, then has a digit is replaced with just the non-digits.