I have a dataset of the following:
> head(data,3)
city state zip_code overall_spend
1 MIDDLESBORO KY 40965 $252,168.12
2 PALM BEACH FL 33411-3518 $369,240.74
3 CORBIN KY 40701 $292,496.03
Now, I want to format the zip_code which has extra parts after -
. For example, in the second row, I have 33411-3518
. After formatting I want to have only 33411
. How can I do this to the whole zip_code column? Also, zip_code is a factor
now
Try