title: How to check if a list contains a certain element in R
body: <p>I have the following list</p>
  
  <pre><code>A = list(c(1,2,3,4), c(5,6,7,8), c(4,6,2,3,1), c(6,2,1,7,12, 15, 16, 10))
  A
  [[1]]
  [1] 1 2 3 4
  
  [[2]]
  [1] 5 6 7 8
  
  [[3]]
  [1] 4 6 2 3 1
  
  [[4]]
  [1]  6  2  1  7 12 15 16 10
  </code></pre>
  
  <p>I want to check if the element <code>2</code> is present each list or not. If it exists, then I need to assign <code>1</code> to that corresponding list.</p>
  
  <p>Thank you in advance.</p>