cnsc {RWsearch} | R Documentation |
Conversion of Standard and Non-Standard Content
Description
cnsc
reads standard content (object in .GlobalEnv
or quoted
characters) and non-standard content. Standard content, including calls,
is evaluated. Non-standard content and non-existing objects (in .GlobalEnv
)
are converted into character chains. Regular lists are kept unchanged.
cnscinfun
is used inside cnsc
. It should not be called directly.
If you find cnsc
and cnscinfun
appealing, copy the code of
cnscinfun
in your package and use it as an hidden function.
Usage
cnsc(...)
cnscinfun()
cnscinfun2(...)
Arguments
... |
Character vectors, standard or non-standard, existing or non-existing
R objects, regular call. Examples : |
Examples
### cnsc
## Non-standard content (nsc1, nsc2), standard content ("stc3", "double word4")
## and regular object (vec) stored in .GlobalEnv are merged.
vec <- c("obj5", "obj6")
cnsc(nsc1, nsc2, "stc3", "double word4", vec)
## Lists, either name in .GlobalEnv or call, are evaluated.
lst <- list(A = c("txt1","txt2","txt3"), B = c("txt4", "txt5"))
cnsc(lst)
cnsc(list(C = c("pkg1","pkg2","pkg3"), D = c("pkg4","pkg5")))
### cnscinfun
fun <- function(...) cnscinfun()
fun(nsc1, nsc2, "stc3", "double word4", vec)
fun(lst)
### cnscinfun used in RWsearch: one line at the begining of each function.
### An easy-to-use Non Standard Evaluation, mainly for characters.
funsort <- function(..., char = NULL) {
words <- if (is.null(char)) cnscinfun() else char
sort(words)
# or more complex code
}
funsort(nsc1, nsc2, "stc3", "double word4", vec)
funsort(char = sample(vec, 5, replace = TRUE))
[Package RWsearch version 5.1.4 Index]