vendredi 1 février 2019

Finding a Pattern in R

I am trying to clean some data. Below is an example of my data.

   test1          test2         test3    
 jsb cjn       kd N069W j        N9DSW 

I want to indicate what column has the pattern N0{num}{num}W in it. The {num} part can be any number between 0-9. This pattern can also appear anywhere in the string. Hence in this case my results would be as follows.

   test1          test2         test3     col
 jsb cjn       kd N069W j        N9DSW      2

Thanks in advance for any help.

Aucun commentaire:

Enregistrer un commentaire