Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

data.table alternative: fuzzy_join #7

Closed
lepennec opened this issue Jan 17, 2018 · 1 comment
Closed

data.table alternative: fuzzy_join #7

lepennec opened this issue Jan 17, 2018 · 1 comment

Comments

@lepennec
Copy link

Hi,
I've seen that you are using data.table extended join abilities to perform some joins. There is an alternative package, probably less efficient than data.table, that avoid the tibble -> data.table -> tibble conversion:

Here is a code snipset showing how to use it in your package for instance here in NNW

header <- header %>%
  dplyr::select(-row) %>% dplyr::arrange(col) %>% 
  dplyr::mutate(col = col,
                to_col = dplyr::lead(col - 1,
                                     default = Inf))

bag %>% fuzzyjoin::fuzzy_left_join(header,
                                         by = c("col" = "col",
                                                "col" = "to_col"),
                                         match_fun = list(`>=`, `<=`)) %>%
  dplyr::rename(col = col.x) %>% dplyr::select(-col.y, -to_col)

I'm not saying this is better than your choice. It just requires less conversion...

Yours,

Erwan

@nacnudus
Copy link
Owner

Hi @lepennec, thanks for the suggestion.

The fuzzyjoin package is excellent, and I have used it in other projects. For this package I chose data.table to avoid a Bioconductor dependency on IRanges, and because it seemed to be faster, but the round-trip conversion is certainly klunky. Hopefully one day we can use tidyverse/dplyr#2240.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants