1

I would like to get names with sp., sp. , and sp, and remove the "Antidesma cuspidatum"

df <- data.frame(name1 = c("Acranthera sp. 01", "Amydrium sp.01", "Alyxia sp.", "Antidesmatoideae sp.", "Antidesma cuspidatum"))

I am using filter_at but "Antidesma cuspidatum" still included since it contains sp

df %>% 
  filter_at(.vars = vars(name1), all_vars(grepl("sp.|sp. ",.)))
                 name1
1    Acranthera sp. 01
2       Amydrium sp.01
3           Alyxia sp.
4  Antidesmatoideae sp.
5 Antidesma cuspidatum

Any suggestions for me?

My desired output

                 name1
1    Acranthera sp. 01
2       Amydrium sp.01
3           Alyxia sp.
4 Antidesmatoideae sp.
UBot
  • 21
  • 5
Anh
  • 735
  • 2
  • 11

0 Answers0