ropensci / taxa

taxonomic classes for R
https://docs.ropensci.org/taxa
Other
48 stars 12 forks source link

Add function for tabular output of `taxonomy` and `taxmap` #58

Open zachary-foster opened 7 years ago

zachary-foster commented 7 years ago

This would try to pack all the information in taxmap or taxonomy into a table, repeating values when necessary. This could be done using the output of get_data().

export_data = function(obj, cols) {
   ...
}

cols would be any set of values in all_names(). I hesitate to have cols output everything by default, because there is a lot in all_names() that most people would not want exported (e.g. is_stem). I also don't want to choose for the user a default set of columns because, in the case of taxmap, most of the interesting stuff will be user-defined. So I am thinking have not default and make the user decide what to export.

sckott commented 6 years ago

Partly implemented. Works in Taxonomy objects, but will simply stop with error if variables not of the same length - Doesn't work with current ex_taxmap dataset.

Fix this in next cran push

zachary-foster commented 6 years ago

I think that is fine. It works if you pick vars from the same table:

ex_taxmap$get_data_frame(c("n_legs", "dangerous"))

# A tibble: 6 x 2
  n_legs dangerous
*  <dbl>     <lgl>
1      4      TRUE
2      4     FALSE
3      4     FALSE
4      2      TRUE
5      0     FALSE
6      0     FALSE
sckott commented 6 years ago

At least that works 😄

zachary-foster commented 6 years ago

Thinking about this more, I am not sure it makes sense to try to make tabular output for taxmap that includes multiple user-defined datasets, since we cant know how these data sets relate to eachother. For taxonomy, all the per-taxon data in get_data would work. For one tabular/vector dataset in a taxmap object, it could return the tabular of the taxonomy part of the object merged with the target data set.