| 1 |
library(xfun) |
| 2 |
litedown::reactor(attr.source = 'r') |
| 3 |
|
| 4 |
library(xfun) |
| 5 |
(z = strict_list(aaa = "I am aaa", b = 1:5)) |
| 6 |
z$a # NULL (strict matching) |
| 7 |
z$aaa # I am aaa |
| 8 |
z$b |
| 9 |
z$c = "you can create a new element" |
| 10 |
|
| 11 |
z2 = unclass(z) # a normal list |
| 12 |
z2$a # partial matching |
| 13 |
|
| 14 |
z3 = as_strict_list(z2) # a strict list again |
| 15 |
z3$a # NULL (strict matching) again! |
| 16 |
|
| 17 |
library(xfun) |
| 18 |
raw_string(head(LETTERS)) |
| 19 |
(x = c("a \"b\"", "hello\tworld!")) |
| 20 |
raw_string(x) # this is more likely to be what you want to see |
| 21 |
|
| 22 |
f = system.file("LICENSE", package = "xfun") |
| 23 |
xfun::file_string(f) |
| 24 |
as.character(xfun::file_string(f)) # essentially a character string |
| 25 |
|
| 26 |
f = system.file("LICENSE", package = "xfun") |
| 27 |
xfun::base64_uri(f) |
| 28 |
|
| 29 |
xfun::grep_sub('a([b]+)c', 'a\\U\\1c', c('abc', 'abbbc', 'addc', '123'), perl = TRUE) |
| 30 |
|
| 31 |
library(xfun) |
| 32 |
f = tempfile() |
| 33 |
writeLines(c("hello", "world"), f) |
| 34 |
gsub_file(f, "world", "woRld", fixed = TRUE) |
| 35 |
file_string(f) |
| 36 |
|
| 37 |
process_file(f, function(x) { |
| 38 |
rep(x, 3) # repeat the content 3 times |
| 39 |
}) |
| 40 |
file_string(f) |
| 41 |
|
| 42 |
library(xfun) |
| 43 |
p = c("abc.doc", "def123.tex", "path/to/foo.Rmd") |
| 44 |
file_ext(p) |
| 45 |
sans_ext(p) |
| 46 |
with_ext(p, ".txt") |
| 47 |
with_ext(p, c(".ppt", ".sty", ".Rnw")) |
| 48 |
with_ext(p, "html") |
| 49 |
|
| 50 |
xfun::is_macos() |
| 51 |
xfun::is_unix() |
| 52 |
xfun::is_linux() |
| 53 |
xfun::is_windows() |
| 54 |
|
| 55 |
xfun::pkg_attach2('tinytex') |
| 56 |
|
| 57 |
n2w(0, cap = TRUE) |
| 58 |
n2w(seq(0, 121, 11), and = TRUE) |
| 59 |
n2w(1e+06) |
| 60 |
n2w(1e+11 + 12345678) |
| 61 |
n2w(-987654321) |
| 62 |
n2w(1e+15 - 1) |
| 63 |
|
| 64 |
xfun::session_info(c('xfun', 'litedown', 'tinytex'), dependencies = FALSE) |
| 65 |
|