Navigation | Overlay |
---|---|
t Navigate files | h Toggle hits |
y Change url to tip of branch | m Toggle misses |
b / v Jump to prev/next hit line | p Toggle partial |
z / x Jump to prev/next missed or partial line | 1..9 Toggle flags |
shift + o Open current page in GitHub | a Toggle all on |
/ or ? Show keyboard shortcuts dialog | c Toggle context lines or commits |
1 |
setMethodS3("wstring", "default", function(..., sep="", envir=parent.frame()) { |
|
2 | 1 |
s <- paste(..., sep=sep) |
3 |
|
|
4 |
# Nothing to do?
|
|
5 |
if (length(s) == 0L) return(s) |
|
6 | 1 |
if (length(s) > 1L) { |
7 | 1 |
Recall <- sys.function(); # base::Recall() does not work with *apply() |
8 | 1 |
return(sapply(s, FUN=Recall, envir=envir)) |
9 |
}
|
|
10 |
|
|
11 |
# Nothing to do?
|
|
12 | 1 |
if (regexpr("{{", s, fixed=TRUE) == -1L) { |
13 | 1 |
return(s) |
14 |
}
|
|
15 |
|
|
16 | 1 |
bfr <- NULL |
17 | 1 |
pattern <- "{{(.*?)}}" |
18 | 1 |
while ((pos <- regexpr(pattern, s, perl=TRUE)) != -1L) { |
19 |
# Parse
|
|
20 | 1 |
len <- attr(pos, "match.length") |
21 | 1 |
head <- substring(s, first=1L, last=pos-1L) |
22 | 1 |
code <- substring(s, first=pos+2L, last=pos+len-3L) |
23 | 1 |
s <- substring(s, first=pos+len) |
24 |
|
|
25 |
# Evaluate
|
|
26 | 1 |
expr <- base::parse(text=code) |
27 | 1 |
value <- eval(expr, envir=envir) |
28 | 1 |
value <- as.character(value) |
29 |
|
|
30 | 1 |
bfr <- c(bfr, head, value) |
31 |
}
|
|
32 | 1 |
bfr <- c(bfr, s) |
33 | 1 |
bfr <- paste(bfr, collapse="") |
34 |
|
|
35 | 1 |
bfr |
36 |
}, protected=TRUE) # wstring() |
Read our documentation on viewing source code .