taxa icon indicating copy to clipboard operation
taxa copied to clipboard

Add arbitrary data vars to `taxa`

Open zachary-foster opened this issue 8 years ago • 6 comments

  • [ ] Add a list to store user data in each taxon
  • [ ] Modify print method of taxon
  • [ ] Modify print method of taxa
  • [ ] Modify print method of hierarchy
  • [ ] Modify print method of hierarchies
  • [ ] Modify print method of taxonomy
  • [ ] Modify the constructor of taxmap to move data from taxon objects to tables / lists. Perhaps add an option to control if data is moved / copied?
  • [ ] Make function to convert taxmap to taxa. Move data to taxon objects.
  • [ ] Make function to convert taxmap to hierarchies. Move data to taxon objects.
  • [ ] Make function to convert taxmap to taxonomy. Move data to taxon objects.
  • [ ] add tests for converters

zachary-foster avatar Jul 18 '17 12:07 zachary-foster

started working on this in e1f1a8f3bd2df3ff91dbf35de5a8490c59c1c0cd (accidentally used commit message I meant to use for taxize - what should have said was related to this issue)

  • added arbitrary attributes to taxon - they have to be a named list
  • changed print method in taxon to print attributes if given
  • added url input to taxon_id
  • changed print method in taxon to print URL from taxon_id if a URL given

sckott avatar Aug 10 '17 23:08 sckott

(work on this is on branch https://github.com/ropensci/taxa/tree/taxize-compat-changes )

@zachary-foster For taxa , hierarchy, etc. How did you image changing these print methods, seems especially hairy since they are arbitrary, so not sure if you imagined printing number of attributes, their names, something else?

sckott avatar Dec 15 '17 23:12 sckott

Hmmm, I think the best way would be to have multiple "print handler" functions for common types (vectors, tables, functions, etc). These would be in a list named by their target class. If the class of the object is not handled by one of these functions, just its name and class are printed. Maybe its length if it is a list. I think that is how I handled the arbitrary data that can be in taxmap$data.

zachary-foster avatar Dec 16 '17 02:12 zachary-foster

okay, makes sense

sckott avatar Dec 16 '17 17:12 sckott

Hi @sckott, I made the print method system I described above for taxmap objects in my most recent commit:

https://github.com/ropensci/taxa/blob/master/R/taxmap--printers.R

I thought it was already set up that way, but I guess I just imagined it. It might be a useful starting point for the taxa attributes printing or it might work for both the taxa and taxmap print methods. Not sure yet

zachary-foster avatar Dec 23 '17 23:12 zachary-foster

thanks, will take a look

sckott avatar Jan 02 '18 18:01 sckott