Regex works, but not on strings in my vector
<p>So I am attempting to use grep to find pattern and replace values within my single column data frame. I basically want grep that says "delete everything after the comma until the end of the string". 
I wrote the expression, and it works on my dummy vector:</p>

<pre><code>&gt; library(stringr)
&gt; pretendvector &lt;- c("Hi","Hi,there","Hi there, how are you")
&gt;str_replace(pretendvector, regex(',.*$'),'')
[1] "Hi"       "Hi"       "Hi there"
</code></pre>

<p>However, when apply the same expression to my vector (since its for stringr I vectorized the column of the dataframe), it returns every value in the column, and does not apply the expression. Does anyone have any idea why this might be? </p>