[R] Is there a tool to find unused functions?

Alexander Engelhardt alex at chaotic-neutral.de
Wed Nov 15 09:44:11 CET 2017


I've inherited a large R codebase which has grown over a few years and a 
few different developers.

It contains many things I'd like to delete:
- Unused functions
- Variable definitions that are never called
- Unreachable code

I'd write that myself, it would even be fun, but I don't want to 
reinvent the wheel.
Is there an R package that can find these things?

I've heard of lintr, but I'm not sure if it's the right tool, since, 
unfortunately, the code is in a folder (not a package) with many R files 
that are sourced from one master file and lintr can only check a single 
file or an actual package, from what I understand. A workaround of 
course would be to concatenate all files into one R script.

I'd appreciate any hints on how to best solve this.

Thanks in advance,
Alex



More information about the R-help mailing list