ropensci / taxa

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

Make `obs` have the option to return data instead of indexes #45

Closed zachary-foster closed 7 years ago

zachary-foster commented 7 years ago

Currently, obs just returns indexes of observations for each taxon. Most of the time that is used to look up some set of values for each taxon, so it would be nice if obs could return that directly.

What had to be done this way:

vapply(obs(data, "my_table"), # For each taxon...
         function(index) sum(data$obs_data[index, id]), numeric(1)) # sum the proportions

Could be done this way:

vapply(obs(data, "my_table", data_col = id), sum, numeric(1))