Skip to contents

Cast an S3-object of class "checkglobals" to a character vector.

Usage

# S3 method for checkglobals
as.character(x, pattern, which = c("global", "import"), ...)

Arguments

x

object inheriting from class "checkglobals".

pattern

an optional regular expression. Only names matching pattern are returned. glob2rx can be used to convert wildcard patterns to regular expressions.

which

a character vector, either "global" to print all unrecognized global variables, "import" to print all detected imported functions and variables, or both (default).

...

additional arguments to configure the output:

  • all.names, a logical value. If TRUE, all object names are returned. If FALSE, names which begin with a . are omitted. Defaults to TRUE.

  • sorted, a logical value indicating if the function/variable names should be sorted alphabetically. Defaults to TRUE.

Value

a character vector containing the names of the global or imported function/variables.

See also

Examples

## R-package from folder
chk <- checkglobals(
  pkg = system.file(
    "unit_tests", "pkg", "testpkg",
    package = "checkglobals"
  )
)
as.character(chk)
#>  [1] "g"               "R6Class"         "aggregate"       "approxfun"      
#>  [5] "coef"            "getMethod"       "globalVariables" "head"           
#>  [9] "is.unit"         "median"          "pvec"            "setGeneric"     
#> [13] "setMethod"       "tail"           

## include only imports
as.character(chk, which = "import")
#>  [1] "R6Class"         "aggregate"       "approxfun"       "coef"           
#>  [5] "getMethod"       "globalVariables" "head"            "is.unit"        
#>  [9] "median"          "pvec"            "setGeneric"      "setMethod"      
#> [13] "tail"