The R Project SVN R

Rev

Rev 59039 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59039 Rev 62026
Line 1... Line 1...
1
% File src/library/methods/man/hasArg.Rd
1
% File src/library/methods/man/hasArg.Rd
2
% Part of the R package, http://www.R-project.org
2
% Part of the R package, http://www.R-project.org
3
% Copyright 1995-2007 R Core Team
3
% Copyright 1995-2013 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{hasArg}
6
\name{hasArg}
7
\alias{hasArg}
7
\alias{hasArg}
8
\title{Look for an Argument in the Call}
8
\title{Look for an Argument in the Call}
Line 13... Line 13...
13
}
13
}
14
\usage{
14
\usage{
15
hasArg(name)
15
hasArg(name)
16
}
16
}
17
\arguments{
17
\arguments{
18
  \item{name}{The unquoted name of a potential argument.}
18
  \item{name}{The name of a potential argument, as an unquoted name or
-
 
19
    character string.}
19
}
20
}
20
\details{
21
\details{
21
  The expression \code{hasArg(x)}, for example, is similar to
22
  The expression \code{hasArg(x)}, for example, is similar to
22
  \code{!missing(x)}, with two exceptions.  First,  \code{hasArg} will look for
23
  \code{!missing(x)}, with two exceptions.  First,  \code{hasArg} will look for
23
  an argument named \code{x} in the call if \code{x} is not a formal
24
  an argument named \code{x} in the call if \code{x} is not a formal
Line 30... Line 31...
30
  Always \code{TRUE} or \code{FALSE} as described above.
31
  Always \code{TRUE} or \code{FALSE} as described above.
31
}
32
}
32
\seealso{ \code{\link{missing}} }
33
\seealso{ \code{\link{missing}} }
33
 
34
 
34
\examples{
35
\examples{
35
ftest <- function(x1, ...) c(hasArg(x1), hasArg(y2))
36
ftest <- function(x1, ...) c(hasArg(x1), hasArg("y2"))
36
 
37
 
37
ftest(1) ## c(TRUE, FALSE)
38
ftest(1) ## c(TRUE, FALSE)
38
ftest(1, 2)  ## c(TRUE, FALSE)
39
ftest(1, 2)  ## c(TRUE, FALSE)
39
ftest(y2=2)   ## c(FALSE, TRUE)
40
ftest(y2 = 2)   ## c(FALSE, TRUE)
40
ftest(y=2)    ## c(FALSE, FALSE) (no partial matching)
41
ftest(y = 2)    ## c(FALSE, FALSE) (no partial matching)
41
ftest(y2 = 2, x=1)  ## c(TRUE, TRUE) partial match x1
42
ftest(y2 = 2, x = 1)  ## c(TRUE, TRUE) partial match x1
42
 
-
 
43
 
-
 
44
}
43
}
45
\keyword{ programming }
44
\keyword{ programming }