I've seen examples here that show how to split a dataframe using column index ranges but how do I split my dataframe with dplyr using strings found in the column? I've purposely created my dataframes so the columns have certain strings in them for future splitting.
Example data:
Site A_Argas A_Arachnicea A_Brus B_Burkoll B_Brielle B_Bact
1 10 0 0 0 0 0
2 0 0 0 10 22 123
3 1 2 3 88 12 546
I want to split this dataframe up based on strings such as "A_" or "B_" and assign them to new dataframes.
For example the output would be:
dataframeA
Site A_Argas A_Arachnicea A_Brus
1 10 0 0
2 0 0 0
3 1 2 3
dataframeB
Site B_Burkoll B_Brielle B_Bact
1 0 0 0
2 10 22 123
3 88 12 546
Because this data is not in long format, I can't seem to figure how to change my old code that I used to split the longform dataframes (for a different analysis).
dataframeA <- data %>% filter("GroupID" == "Arachnids") # where "A_" in column headers signify arachnid species
dataframeB <- data %>% filter("GroupID" == "Bacteria") # where all "B_" in the column headers are bacterial species