I have a large data frame that contains Address Information (CUST_ADDRESS_1 and CUST_ADDRESS_2).
CUST_ADDRESS_1 should only contain street information such as 123 Anywhere Drive while CUST_ADDRESS_2 should only contain Suite information such as Suite 23.
I want to find all of the instances where Suite information is located in CUST_ADDRESS_1 and place it in CUST_ADDRESS_2.
I'm okay if Suite information replaces current data in CUST_ADDRESS_2 but I only want the data replaced if it meets that condition.
For example:
BEFORE
CUST_ADDRESS_1 CUST_ADDRESS_2
986 Eastern Drive Suite 180
763 Sunset Drive, Suite 2 Attn: Mark Matthews
543 Roanoke Lane
4201 Practice Road, Suite 18
AFTER
CUST_ADDRESS_1 CUST_ADDRESS_2
986 Eastern Drive Suite 180
763 Sunset Drive Suite 2
543 Roanoke Lane
4201 Practice Road, Suite 18
If tried the following but if Suite info is not found in CUST_ADDRESS_1 it deletes the data in CUST_ADDRESS_2.
RosterFinal$CUST_ADDRESS_2 <- if_else(grepl("SUITE",RosterFinal$CUST_ADDRESS_1),substr(RosterFinal$CUST_ADDRESS_1,(regexpr("SUITE", RosterFinal$CUST_ADDRESS_1)-1),nchar(RosterFinal$CUST_ADDRESS_1)),if_else(grepl(" STE",RosterFinal$CUST_ADDRESS_1),substr(RosterFinal$CUST_ADDRESS_1,(regexpr(" STE", RosterFinal$CUST_ADDRESS_1)-1),nchar(RosterFinal$CUST_ADDRESS_1)),if_else(grepl(" #",RosterFinal$CUST_ADDRESS_1),substr(RosterFinal$CUST_ADDRESS_1,(regexpr(" #", RosterFinal$CUST_ADDRESS_1)-1),nchar(RosterFinal$CUST_ADDRESS_1)),"")))