Remove everything after last space with stringr
<p>I have data that looks like this:</p>

<pre><code>df &lt;- tribble(
    ~name, ~value,
    "Jake Lake MLP", 10, 
    "Bay May CE", 5,
    "Drake Cake Jr. DSF", 9.1,
    "Sam Ram IR QQQZ", 1
)
</code></pre>

<p>I want to trim all the names so that they are:</p>

<pre><code>"Jake Lake",
"Bay May", 
"Drake Cake Jr.",
"Sam Ram IR"
</code></pre>

<p>Basically removing everything after the last space.</p>

<p>I tried:</p>

<pre><code>df %&gt;% mutate(name = str_replace(name, "\\s.*$", ""))
</code></pre>

<p>But it's not quite what I want!</p>