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:
> library(stringr)
> pretendvector <- c("Hi","Hi,there","Hi there, how are you")
>str_replace(pretendvector, regex(',.*$'),'')
[1] "Hi" "Hi" "Hi there"
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?