File: utils.R

package info (click to toggle)
r-cran-lazyeval 0.2.2-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 596 kB
  • sloc: ansic: 310; sh: 9; makefile: 2
file content (37 lines) | stat: -rw-r--r-- 707 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"%||%" <- function(x, y) if(is.null(x)) y else x

is_atomic <- function(x) {
  typeof(x) %in% c("logical", "integer", "double", "complex", "character", "raw")
}

is_vector <- function(x) {
  is_atomic(x) || is.list(x)
}

has_names <- function(x) {
  nms <- names(x)
  if (is.null(nms)) {
    rep(FALSE, length(x))
  } else {
    !(is.na(nms) | nms == "")
  }
}

substitute_ <- function(x, env) {
  if (identical(env, globalenv())) {
    env <- as.list(env)
  }

  call <- substitute(substitute(x, env), list(x = x))
  eval(call)
}

#' Generate a missing argument.
#'
#' @export
#' @examples
#' f_interp(~f(x = uq(missing_arg())))
#' f_interp(~f(x = uq(NULL)))
missing_arg <- function() {
  quote(expr = )
}