S4 method for ensuring dplyr distinct selects rows containing distinct S4 objects

36 Views Asked by At

I am implementing an S4 class called Taxa. Objects of class Taxa form a column in a tbl_df. For example:

 my_tbl <- tibble::tibble(taxa = list(Taxa(Taxon(family = "test")), Taxa(Taxon(family = "test1"))))

which gives:

# A tibble: 2 x 1
  taxa
  <list>
1 <Taxa>
2 <Taxa>

I would like to be able to select the distinct rows of my_tbl using dplyr::distinct. For example:

dplyr::distinct(my_tbl, taxa)

However this returns the error Error: Unsupported type S4. Is there a way to implement a method for Taxa that would help determine which elements of the column of Taxa objects are distinct?

0

There are 0 best solutions below