russHyde / dupree

{dupree} helps identify code blocks that have a high level of similarity in a set of R files
https://russhyde.github.io/dupree/
Other
37 stars 0 forks source link

Function for extracting a template of any duplicated code #27

Open russHyde opened 5 years ago

russHyde commented 5 years ago

Say these two code blocks are identified by dupree

my_code <- some_data %>%
   a_really() %>%
   long_pipeline() %>%
   bespoke_function1()
.
.
.
some_data %>%
    a_really %>%
    long_pipeline() %>%
    bespoke_function2()

Is there some way that dupree could take the details of these two code blocks (file / line) and return a template for abstracting out the common code?

new_function <- function(x) {
  x %>% a_really() %>% long_pipeline()
}