title: How to fix a simple code to conditional mutate
body: <p>I need to create a new variable based on values in the old column in the data frame. If the existing value ends with .0, the new value in the new column will be 0 / But If the existing value ends with .1 the new value in the new column will be 1 / But the small code I used does not distinguish between 11.0 and 11.1 (and in other pairs with a similar pattern).</p>
  
  <p>I attach an example and the unsuccessful solution</p>
  
  <pre><code>c&lt;-c(1.1,1.0, 0.1, 0.0, 80.1, 80.0, 91.1, 91.0, 11.1,11.0)
  b&lt;-c(1,1,0,0,80,80,91,91,11,11)
  
  cb&lt;-data.frame(b,c) #this is exaple to my data
  
  cb&lt;-mutate(cb, a = ifelse(grepl( ".1" ,   cb$c ), 1, 0 )) #this is my unsuccessful solution
  
  a&lt;-c(1,0,1,0,1,0,1,0,1,0)
  abc&lt;-data.frame(a,c,b) # This is the desired result
  </code></pre>
  
  <p>As can be seen in the code, for values 81.0 and 11.0, an incorrect value of 1 was created instead of 0</p>