Replace values that starts with "<" in a data frame in r
Using gsub with a regular expression to replace every string starting with a &quot;&lt;&quot; with NA.
x &lt;- c(&quot;&lt;0.01&quot;, &quot;0.027&quot;, &quot;&lt;0.01&quot;, &quot;&lt;0.01&quot;, &quot;0.2&quot;, &quot;0.22&quot;, &quot;0.04&quot;, &quot;0.09&quot;)
gsub(&quot;&lt;.*&quot;, NA, x)
# [1] NA      &quot;0.027&quot; NA      NA      &quot;0.2&quot;   &quot;0.22&quot;  &quot;0.04&quot;  &quot;0.09&quot;