I want to get a result of the last 2 strings in these vectors (i.e.: "Dalkey", "South Co. Dublin" from address_1 and " Dublin 4", " South Dublin City" from address_2
Thanks FJCC for your reply. However, it's not working for my scenario. I have a column where it contains all the vectors (example in screenshot). I want to get only the last two items from these vectors. I tried with different functions: lapply, split, tail,... it didn't work.
Your first post provided data, and FJCC kindly showed how to complete your requested task on that data, but your follow up message indicates that your data is different. Therefore please take a moment to make a reproducible example, such that it presents the issue you wish to solve.
I would really encourage you to review the following guide, FAQ: Tips for writing R-related questions. For example, the guide emphasizes asking coding questions with formatted code-chunks and a reprex, which would make it easier for people who want to help you to pick up your issue and attempt to run with a solution.
A handy way to supply some sample data is the dput() function. In the case of a large dataset something like dput(head(mydata, 100)) should supply the data we need.
Thanks a lot for that, jrkrideau. I definitely need that.
And by the way, I've found the solutions for my issue. I used the str_match() and it works the way I wanted. I don't know yet how to share it here. There are a lot for me to learn, I just need a starting point.
Without seeing the code I think your approach is okay but something like tail() is likely to be a lot less cumbersome. If you supply a bit of sample data someone here should be able to give some pointers.