I'm a beginner in R programming language, and I'm using RStudio to work on this project I have. My dataframe has a column for the zone of the mall, but some zones are actually subzones of a bigger zone, so they are called something like: Ikea 1, Ikea 2, Ikea 3, etc. I want to create a new column with the bigger zone for each entry.
The dataframe looks like this:
ID ENTRY ZONE
1 13:39:40 Casual Dinnerware
2 15:28:43 Van Thiel 3
3 10:41:05 Caracole 7
4 16:37:31 Entrance
I want to add a new column that has the "mother" zone, in case it is a subzone, for the given example, I want something like:
ID ENTRY ZONE NEW ZONE
1 13:39:40 Casual Dinnerware Casual Dinneware
2 15:28:43 Van Thiel 3 Van Thiel
3 10:41:05 Caracole 7 Caracole
4 16:37:31 Entrance Entrance
Note that not every zone is a subzone!
My ideia was to analyse each entry and if the zone ended with a number, I would remove the number and write the rest in the new column. I already read a few questions that I thought that would help, related to regular expressions and all (like this one), but I couldn't get this to work.
Thank you for your time, if you have any questions, let me know!