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

Michael Hannon jmhannon.ucdavis at gmail.com
Wed Nov 15 10:44:09 CET 2017


mvbutils::foodweb produces a graphical display of the hierarchy (or
network or ...) of function calls.  Isolated functions are not called.
This might help you.

-- Mike


On Wed, Nov 15, 2017 at 12:44 AM, Alexander Engelhardt
<alex at chaotic-neutral.de> wrote:
> 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
>
> ______________________________________________
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list