Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Without seeing your data, it is hard to offer a suggestion on how to proceed. Here is an example with some plain character strings that might help you get started on finding a solution of your own.</p> <p>First, some sample data (which probably looks nothing like your data):</p> <pre><code>x &lt;- c("Some text with a strange CPXY180D2324 string stuck in it.", "Some more text with CPXY180D2131 strange strings CPCY180D2139 stuck in it.", "Even more text with strings that CPXY180D2131 don't make much sense.", "I'm CPXY180D2324 tired CPXY180D2324 of CPXY180D2324 text with CPXY180D2131 strange strings CPCY180D2139 stuck in it.") </code></pre> <p>We can split it by spaces. This is another area it might not fit with your actual problem, but again, this is just to help you get started (or help others provide a much better answer, as may be the case.)</p> <pre><code>x2 &lt;- strsplit(x, " ") </code></pre> <p>Search the split data for values matching your regex pattern. Create a <code>data.frame</code> that includes the line numbers and the matched string.</p> <pre><code>temp &lt;- do.call(rbind, lapply(seq_along(x2), function(y) { data.frame(line = y, value = grep("([A-Z0-9]{12})", x2[[y]], value = TRUE)) })) temp # line value # 1 1 CPXY180D2324 # 2 2 CPXY180D2131 # 3 2 CPCY180D2139 # 4 3 CPXY180D2131 # 5 4 CPXY180D2324 # 6 4 CPXY180D2324 # 7 4 CPXY180D2324 # 8 4 CPXY180D2131 # 9 4 CPCY180D2139 </code></pre> <p>Create your <code>data.frame</code> of line numbers and counts.</p> <pre><code>with(temp, data.frame( lines = tapply(line, value, paste, collapse = ", "), count = tapply(line, value, length))) # lines count # CPXY180D2324 1, 4, 4, 4 4 # CPCY180D2139 2, 4 2 # CPXY180D2131 2, 3, 4 3 </code></pre> <p>Anyway, this is purely a guess (and me killing time....)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload