title: Function to loop through a list of columns in a dataframe in R
body: <p>I'm trying to create a function or a loop in r that can loop through a list of columns for a specific string i.e '123', and create a new column with an indicator variable i.e 0 or 1 if the string is present in the defined columns.</p>
  
  <p>Please see example below -
  I would like to create a function/loop that will detect if the string '123' is found in any of the columns from df1 to df5, if the string is found then new_column will be 1, if not then it will be 0</p>
  
  <pre><code>  index df1 df2 df3 df4 df5 new_column
  1     1 123 999 999 999 999          1
  2     2 999 123 999 999 999          1
  3     3 123 999 999 999 999          1
  4     4 999 999 999 999 999          0
  5     5 999 999 123 999 999          1
  6     6 999 999 999 999 999          0
  </code></pre>