ropensci / taxa

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

Need non-NSE versions of functions #180

Open zachary-foster opened 5 years ago

zachary-foster commented 5 years ago

Occasionally, I run into problems with the NSE in things like filter_taxa, like this:

> obj %>%
+     mutate_obs("tax_prop", sample_prop = obj$data$tax_prop[[sample]]) %>%
+     filter_taxa(obj$data$tax_prop[["X700114488"]] >= 0.001 | obj$data$tax_prop[["X700114430"]] >= 0.001)
Error: `data` must be uniquely named but has duplicate elements
In addition: Warning message:
 Hide Traceback

 Rerun with Debug
 Error: `data` must be uniquely named but has duplicate elements 
14.
FUN(X[[i]], ...) 
13.
lapply(rlang::quos(...), rlang::eval_tidy, data = self$data_used(...)) at taxonomy--class.R#1231
12.
private$parse_nse_taxon_subset(...) at taxonomy--class.R#749
11.
obj$filter_taxa(..., subtaxa = subtaxa, supertaxa = supertaxa, 
    drop_obs = drop_obs, reassign_obs = reassign_obs, reassign_taxa = reassign_taxa, 
    invert = invert, keep_order = keep_order) at taxonomy--s3.R#529
10.
filter_taxa.Taxmap(., obj$data$tax_prop[["X700114488"]] >= 0.001 | 
    obj$data$tax_prop[["X700114430"]] >= 0.001) at taxonomy--s3.R#487
9.
filter_taxa(., obj$data$tax_prop[["X700114488"]] >= 0.001 | obj$data$tax_prop[["X700114430"]] >= 
    0.001) 
8.
function_list[[k]](value) 
7.
withVisible(function_list[[k]](value)) 
6.
freduce(value, `_function_list`) 
5.
`_fseq`(`_lhs`) 
4.
eval(quote(`_fseq`(`_lhs`)), env, env) 
3.
eval(quote(`_fseq`(`_lhs`)), env, env) 
2.
withVisible(eval(quote(`_fseq`(`_lhs`)), env, env)) 
1.
obj %>% mutate_obs("tax_prop", sample_prop = obj$data$tax_prop[[sample]]) %>% 
    filter_taxa(obj$data$tax_prop[["X700114488"]] >= 0.001 | 
        obj$data$tax_prop[["X700114430"]] >= 0.001) 

Yet, this works:

  to_use <- obj$data$tax_prop[["X700114488"]] >= 0.001 | obj$data$tax_prop[["X700114430"]] >= 0.001
  obj %>%
    mutate_obs("tax_prop", sample_prop = obj$data$tax_prop[[sample]]) %>%
    filter_taxa(to_use) 

It would be nice to figure out what is happening here, but either way, having a filter_taxa_ that does not use NSE would be useful.