The R Project SVN R

Rev

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

Rev 70848 Rev 77213
Line 60... Line 60...
60
  collection is specified, so for example \code{mode = "special"} will
60
  collection is specified, so for example \code{mode = "special"} will
61
  seek any type of function.)
61
  seek any type of function.)
62
}
62
}
63
\note{
63
\note{
64
  With \code{get0()}, instead of the easy to read but somewhat
64
  With \code{get0()}, instead of the easy to read but somewhat
-
 
65
  inefficient
65
  inefficient \preformatted{
66
  \preformatted{
66
  if (exists(myVarName, envir = myEnvir)) {
67
    if (exists(myVarName, envir = myEnvir)) {
67
    r <- get(myVarName, envir = myEnvir)
68
      r <- get(myVarName, envir = myEnvir)
68
    ## ... deal with r ...
69
      ## ... deal with r ...
-
 
70
    }
69
  }
71
  }
70
}
-
 
71
  you now can use the more efficient (and slightly harder to read) \preformatted{
72
  you now can use the more efficient (and slightly harder to read)
-
 
73
  \preformatted{
72
  if (!is.null(r <- get0(myVarName, envir = myEnvir))) {
74
    if (!is.null(r <- get0(myVarName, envir = myEnvir))) {
73
    ## ... deal with r ...
75
      ## ... deal with r ...
-
 
76
    }
74
  }
77
  }
75
}
78
}
76
}
-
 
77
\value{
79
\value{
78
  \code{exists():} Logical, true if and only if an object of the correct
80
  \code{exists():} Logical, true if and only if an object of the correct
79
  name and mode is found.
81
  name and mode is found.
80
 
82
 
81
  \code{get0():} The object---as from \code{\link{get}(x, *)}---
83
  \code{get0():} The object---as from \code{\link{get}(x, *)}---