title: Create average over range of values (Income range) in factor except one value
body: <p>I want to create an average over the range of values in order to receive numerical values so that I can run a regression. However, when I try my code, the value &quot;100000&quot; gets excluded so that I don't have it in my data anymore.</p>
  <p>Can anyone tell me how to create an average over the ranges except from &quot;100000&quot;?</p>
  <pre><code>df1$Income[df1$Income %in% c(&quot;Prefer not to say&quot;)] &lt;- NA
  df1$Income &lt;- gsub(&quot;[,€]&quot;,&quot;&quot;, df1$Income)
  df1$Income &lt;- gsub(&quot;[[:alpha:]]&quot;,&quot;&quot;, df1$Income)
  table(df1$Income)
  df1$Inc &lt;- factor(df1$Income, levels = c(&quot;0 – 9999&quot;, &quot;10000 – 19999&quot;, &quot;20000 – 29999&quot;, &quot;30000 – 39999&quot;,
                                           &quot;40000 – 59999&quot;, &quot;60000 – 79999&quot;, &quot;80000 – 99999&quot;, &quot;100000&quot;), ordered = TRUE)
  df1$Inc &lt;- as.character(df1$Inc)
  df1$av.Inc &lt;- sapply(strsplit(df1$Inc, &quot; – &quot;), function(i) mean(as.numeric(i)))
  table(df1$av.Inc)
  </code></pre>