you could maybe adapt this approach to find the functions.
Then you would have a seperate challenge to look up the functions against the possible packages that they might have come from
To start: this was fun for me. Thanks for this cool problem!
You can use the parse function to convert a script into an expression. Then you can go through the expression, collect any functions called, flatten subexpressions, and repeat until nothing's left to flatten.
We can identify expressions because they have a length: the number of subexpressions plus tokens they contain. Tokens are the smallest unit of a language. For example, 1 + 2 has three tokens: 1, +, and 2.
get_calls <- function(filepath) {
code <- parse(filepath)
tokens <- as.list(code)
calls <- c()
while (TRUE) {
any_unpacked <- FALSE
for (ii in seq_along(tokens)) {
part <- tokens[[ii]]
# Cal…