I\'d like to strip this column so that it just shows last name - if there is a comma I\'d like to remove the comma and anything after it. I have data column that is a mix of
Also try strsplit:
strsplit
string <- c("Sample, A", "Tester", "Wifred, Nancy", "Day, Bobby Jean", "Morris") sapply(strsplit(string, ","), "[", 1) #[1] "Sample" "Tester" "Wifred" "Day" "Morris"