Skip to content
Prev 170439 / 398503 Next

Distinguishing variables from functions with the same name

Berwin A Turlach wrote:
hmm, looks like you can do it with just one call to grep:

grep -R -P --include=*.R 'get\(.*mode\s*=\s*"(?!function|any)' .
# ./src/library/utils/R/Sweave.R:        syntax <- get(syntax, mode="list")
# ./src/library/utils/R/Sweave.R:        syntax <- get(sname, mode = "list")
# ./src/library/utils/R/Sweave.R:        s <- get(sname, mode="list")
# ./src/library/tools/R/QC.R:            al <- get(al, envir = code_env,
mode = "list")
# ./src/library/tools/R/QC.R:            al <- get(al, envir = ns_env,
mode = "list")
# ./src/library/tools/R/QC.R:                al <- get(al, envir =
data_env, mode = "list")

(you'll need grep compiled with --enable-perl-regexpr for this)

note this fancy comment in ?get:

" 'mode' here is a mixture of the meanings of 'typeof' and 'mode'"

vQ