Debian Codegraph @

R/tick.R

raw
1 format_title <- function(x, width, footnote = TRUE) {
2 align(str_trunc(x, width, if (footnote) "untick_footnote" else "untick"))
3 }
4
5 tick_names_if_needed <- function(x) {
6 names(x) <- tick_if_needed(names(x))
7 x
8 }
9
10 tick_if_needed <- function(x) {
11 # Compatibility with R 3.4
12 if (is.null(x)) {
13 return(NULL)
14 }
15 needs_ticks <- !is_syntactic(x)
16 x[needs_ticks] <- tick(x[needs_ticks])
17 x
18 }
19
20 is_syntactic <- function(x) {
21 # Compatibility with R 3.4
22 if (is.null(x)) {
23 return(logical())
24 }
25 ret <- make.names(x) == x
26 ret[is.na(x)] <- FALSE
27 ret
28 }
29
30 is_ambiguous_string <- function(x) {
31 !is.na(x) & grepl("^$|^ | $|\\\\|\"", x)
32 }
33
34 tick <- function(x) {
35 ifelse(is.na(x), "NA", encodeString(x, quote = "`"))
36 }