0

I am trying to remove rows from a table based on the 'taxonomy' column, specifically removing rows with a class of 'unidentified'. However, this column contains information outside of class such as different kingdoms and phyla. Methods I've tried such as filter don't appear to be working, is there a simple method for focusing on certain information in a column?

final=counts\[!(counts$taxonomy == ";c__unidentified")\]

counts= filter(counts, counts$taxonomy != "c_unidentified")

These are examples of current attempts

NelsonGon
  • 13,015
  • 7
  • 27
  • 57
Jess
  • 1
  • 1
    Could you please add sample data with `dput(head(df,n))`? You should not need to do `counts$taxonomy` in `filter`. – NelsonGon Apr 01 '22 at 18:59
  • 2
    Does this answer your question? [Subset dataframe by multiple logical conditions of rows to remove](https://stackoverflow.com/questions/6244217/subset-dataframe-by-multiple-logical-conditions-of-rows-to-remove) – NelsonGon Apr 01 '22 at 19:00
  • The first version needs a `,` after the filter predicate, otherwise columns instead of rows are indexed (index order is `some_two_dimensional_structure[row, column]`). The second seems to be missing the leading ";" in the filter predicate (unless dplyr::filter ist masked by another package's filter function; to make sure, invoke dplyr::filter) –  Apr 01 '22 at 19:01

0 Answers0