简体   繁体   中英

how to remove specific character from rows of dataframe in R

I have a data frame containing three columns and first column is Species_Name which contain all species name but i want to remove those rows which are undetermined like "Salmonella sp" and want to keep only those rows which have full determined name like Salmonella enterica or bongori and so on. I tried following code but its not working. please give any suggestions.

dfcox1 <- dfcox1 %>%
filter(Species_Name != "Salmonella sp")

Welcome on stackoverflow.com! Please create reproducible examples so that other people have it easier to help you, which is especially easy when working with GNU R .

If you want to remove a row in a dataframe according to a specific regular expression (eg the row name ending with sp ), you can do so as follows):

iris %>%
  dplyr::filter(!stringr::str_detect(Species, "sp"))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM