Find all symbols used in a function or language object.

find_symbols(x)

Arguments

x

A language object or function.

Value

A character vector of the symbols used in the object.

Examples

# Find all symbols used in the lm function
find_symbols(utils::install.packages)
#>   [1] "!"                                  "!="                                
#>   [3] "$"                                  "%in%"                              
#>   [5] "&"                                  "&&"                                
#>   [7] "("                                  "..."                               
#>   [9] ".Library"                           ".Platform"                         
#>  [11] ".R_LIBS"                            ".TkUp"                             
#>  [13] ".find_install_order"                ".install.macbinary"                
#>  [15] ".install.winbinary"                 ".libPaths"                         
#>  [17] ".make_dependency_list"              ".standard_regexps"                 
#>  [19] "::"                                 ":::"                               
#>  [21] "<"                                  "<-"                                
#>  [23] "=="                                 ">"                                 
#>  [25] "DL"                                 "GUI"                               
#>  [27] "INSTALL_opts"                       "NROW"                              
#>  [29] "Ncpus"                              "OK"                                
#>  [31] "OS.type"                            "R.home"                            
#>  [33] "R.version"                          "Sys.getenv"                        
#>  [35] "Sys.getpid"                         "Sys.glob"                          
#>  [37] "Sys.setenv"                         "Sys.which"                         
#>  [39] "["                                  "[["                                
#>  [41] "aDL"                                "action"                            
#>  [43] "all"                                "ans"                               
#>  [45] "any"                                "args"                              
#>  [47] "args0"                              "as.numeric_version"                
#>  [49] "askYesNo"                           "av"                                
#>  [51] "av1"                                "av2"                               
#>  [53] "available"                          "available.packages"                
#>  [55] "available_packages_filters_db"      "available_packages_filters_default"
#>  [57] "basename"                           "bins"                              
#>  [59] "binvers"                            "c"                                 
#>  [61] "capabilities"                       "cat"                               
#>  [63] "cbind"                              "character"                         
#>  [65] "clean"                              "close"                             
#>  [67] "cmd"                                "cmd0"                              
#>  [69] "colnames"                           "config"                            
#>  [71] "configure.args"                     "configure.vars"                    
#>  [73] "conn"                               "contrib.url"                       
#>  [75] "contriburl"                         "contriburl2"                       
#>  [77] "cwd"                                "data.frame"                        
#>  [79] "dependencies"                       "deps"                              
#>  [81] "destdir"                            "destfile"                          
#>  [83] "df"                                 "dir"                               
#>  [85] "dir.create"                         "dir.exists"                        
#>  [87] "dirname"                            "dirs"                              
#>  [89] "download.file"                      "download.packages"                 
#>  [91] "e"                                  "endsWith"                          
#>  [93] "env"                                "f"                                 
#>  [95] "f2"                                 "failed"                            
#>  [97] "fil"                                "file"                              
#>  [99] "file.access"                        "file.copy"                         
#> [101] "file.exists"                        "file.path"                         
#> [103] "files"                              "filters"                           
#> [105] "flush.console"                      "fn"                                
#> [107] "for"                                "found"                             
#> [109] "foundpkgs"                          "function"                          
#> [111] "getConfigureArgs"                   "getConfigureVars"                  
#> [113] "getDependencies"                    "getDeps"                           
#> [115] "getOption"                          "get_install_opts"                  
#> [117] "get_package_name"                   "get_timeout"                       
#> [119] "gettext"                            "gettextf"                          
#> [121] "getwd"                              "grep"                              
#> [123] "grepl"                              "gsub"                              
#> [125] "hasArchs"                           "hasSrc"                            
#> [127] "have_spaces"                        "i"                                 
#> [129] "if"                                 "inherits"                          
#> [131] "interactive"                        "inuse"                             
#> [133] "invisible"                          "is.character"                      
#> [135] "is.list"                            "is.logical"                        
#> [137] "is.na"                              "is.null"                           
#> [139] "isTRUE"                             "keep_outputs"                      
#> [141] "later"                              "length"                            
#> [143] "lib"                                "libpath"                           
#> [145] "libs_only"                          "libs_used"                         
#> [147] "list"                               "make.packages.html"                
#> [149] "match"                              "message"                           
#> [151] "method"                             "mfile"                             
#> [153] "missing"                            "msg"                               
#> [155] "n"                                  "na"                                
#> [157] "names"                              "nchar"                             
#> [159] "needsCmp"                           "next"                              
#> [161] "ngettext"                           "nonlocalrepos"                     
#> [163] "normalizePath"                      "nrow"                              
#> [165] "nzchar"                             "ok"                                
#> [167] "oldrlibs"                           "on.exit"                           
#> [169] "out"                                "outdir"                            
#> [171] "outfile"                            "outfiles"                          
#> [173] "output"                             "p"                                 
#> [175] "p0"                                 "paste"                             
#> [177] "paste0"                             "path.expand"                       
#> [179] "path.sep"                           "pkg"                               
#> [181] "pkgType"                            "pkgnames"                          
#> [183] "pkgs"                               "platform"                          
#> [185] "print"                              "quiet"                             
#> [187] "readLines"                          "repos"                             
#> [189] "res"                                "return"                            
#> [191] "row.names"                          "rownames"                          
#> [193] "s2"                                 "sQuote"                            
#> [195] "search"                             "select.list"                       
#> [197] "seq_len"                            "setdiff"                           
#> [199] "setwd"                              "shQuote"                           
#> [201] "shortPathName"                      "sort"                              
#> [203] "sort.list"                          "sprintf"                           
#> [205] "srcOnly"                            "srcpkgs"                           
#> [207] "srcvers"                            "startsWith"                        
#> [209] "status"                             "stderr"                            
#> [211] "stop"                               "strsplit"                          
#> [213] "strwrap"                            "sub"                               
#> [215] "sum"                                "suppressWarnings"                  
#> [217] "system"                             "system2"                           
#> [219] "tcltk"                              "tempdir"                           
#> [221] "tempfile"                           "this"                              
#> [223] "timeout"                            "tlim"                              
#> [225] "tlim_cmd"                           "tmpd"                              
#> [227] "tmpd2"                              "tolower"                           
#> [229] "tools"                              "try"                               
#> [231] "tryCatch"                           "tss"                               
#> [233] "type"                               "type2"                             
#> [235] "unique"                             "unlink"                            
#> [237] "unlist"                             "update"                            
#> [239] "upkgs"                              "urls"                              
#> [241] "userdir"                            "valid_package_version"             
#> [243] "verbose"                            "warning"                           
#> [245] "web"                                "writeLines"                        
#> [247] "{"                                  "|"                                 
#> [249] "||"                                

# Does not find names of arguments
find_symbols(quote(foo(a = A)))
#> [1] "A"   "foo"
#> [1] "A"   "foo"

find_symbols(quote(function(x = X) NULL))
#> [1] "X"        "function"
#> [1] "function" "X"