Take the 2-minute tour ×

How can you find the names and locations of all the functions that have a specific argument? Is there a way to find them for functions in the global environment, attached packages, and installed packages?

share|improve this question
@Arun: Yes, but it's tangential to the original question, so 1) it's unlikely anyone will find it by searching, and 2) it's likely that question will be deleted. –  Joshua Ulrich Jan 21 '13 at 0:01
Any particular reason you're asking? After all, the name of an argument to a function is pretty much arbitrary, e.g., the arguments x and arg in agstudy's excellent answer. Some wiseacre like me, seeing your request, could go off and rewrite his packages so the argument xlim,ylim suddenly become xlims,ylims just to drive you crazy. :-) –  Carl Witthoft Jan 21 '13 at 13:37

1 Answer 1

up vote 14 down vote accepted

I assume that you ask the question just to not lose Ben great answer. Here I slightly modify Ben answer to search for any argument :

uses_arg <- function(x,arg) 
  is.function(fx <- get(x)) && 
  arg %in% names(formals(fx))

For example to get function with na.rm argument :

basevals <- ls(pos="package:base")      ## package name : here I use the base package


better to name argument of ls in conjunction with asNamespace :

basevals  <- ls(asNamespace('base'))
share|improve this answer
am a little confused by ## base and stats packages, I don't see anything from stats, just base? –  Silverfish Jan 21 '13 at 2:11
@Silverfish you're right It is typo ! I correct it. –  agstudy Jan 21 '13 at 2:15

Your Answer


