Capitalize the first letter of each word in a string except `in`, `the` `of`
<p>How can I capitalize first letter of each word except certain words</p>

<pre><code>x &lt;- c('I like the pizza', 'The water in the pool')
</code></pre>

<p>I expect the output to be</p>

<pre><code>c('I Like the Pizza', 'The Water in the Pool')
</code></pre>

<p>Currently I am using   </p>

<pre><code>gsub('(^|[[:space:]])([[:alpha:]])', '\\1\\U\\2', x, perl=T) 
</code></pre>

<p>Which capitalizes the first letter of each word.</p>