Understanding separate fun from tidyr package - UseMethod(), simplifyPieces()

I'm trying to optimize my package to have minimum package dependencies. My first goal is to replicate separate() function from tidyr package. So for now I'm trying to understand its components.

Looking through it's code on github I'm getting stuck at understanding the UseMethod() in:

separate <- function(data, col, into, sep = "[^[:alnum:]]+", remove = TRUE,
                     convert = FALSE, extra = "warn", fill = "warn", ...) {

-Where is UseMethod defined?
-It is not imported from another package, as far I can see.

and simplifyPieces():

simp <- simplifyPieces(pieces, n, fill == "left")

-Same for this fun, where is it defined? I don't see its code and what it should do.
-It is not imported from another package, as far I can see.

Thank you.

If you're trying to write a package with zero dependencies, you'll probably want to get familiar with the contents of Writing R Extensions, especially Generic functions and methods.

Colin Fay took Writing R Extensions and put it into bookdown format, which makes it more navigable:

Also, tidyr, like many R packages, uses RCPP, so you'll want to take a look at that as well, since, if you're not finding a function or a method in the R code in a package, it's probably from RCPP or comes from another foreign-language interface, or it's a generic/base method:


Thank you, Mara! :slight_smile: