Hi, I have a dataframe like the one below. I want to make a new column called "Species". I then want to populate that column with either "species1" or "species2", depending on the end of the sample ID (in the ID column). I have an example below of what I have tried, trying to use mutate, ends_with, and if_else, but I haven't figured out how to make it work yet.
This regular expression will match either species1 or species2 at the end of a word followed by an underscore (_). What [12] means is either 1 or 2, and no other character.
You may find this site helpful to understand different regex you find online: https://regexr.com