|
- detectBadName <- function(name)
- {
- !grepl("^[[:alpha:]]([[:alnum:]]|[_.])*$", name)
- }
-
- getType <- function(object)
- {
- if (is.list(object))
- {
- paste0("+",
- if(is.data.frame(object)) "D"
- else if(isS4(object)) "S"
- else "L")
- } else
- {
- paste0(" ",
- if(is.function(object)) "f"
- else if(is.numeric(object)) "n"
- else if(is.character(object)) "c"
- else if(inherits(object, "formula")) "F"
- else if(is.logical(object)) "l")
- }
- }
-
- listObjects <- function()
- {
- noms <- ls(envir = .GlobalEnv)
- objects <- mget(noms, envir = .GlobalEnv)
- types <- lapply(objects, getType)
-
- vars <- lapply(noms, function(nom)
- {
- if (detectBadName(nom))
- {
- nom <- gsub("\\n", "\\\\n", nom)
- nom <- gsub("\\t", "\\\\t", nom)
- nom <- gsub("\\`", "\\\\`", nom)
- paste0("`", nom, "`")
- } else nom
- })
-
- # if R-object-browser-fancy-char ?
- noms <- gsub("\\n", "⏎", noms)
- noms <- gsub("\\t", "⭾", noms)
- noms <- gsub("\\`", "\\\\`", noms)
-
- Map(cat, types, noms, vars, "\n") -> nul
- }
-
- listObjects()
-
- objectContent <- function(x)
- {
- if (is.list(x))
- {
- noms <- if (is.null(names(x))) 1:length(x) else names(x)
- objects <- mget(noms, envir = x)
- types <- lapply(objects, get_type)
-
- noms <- gsub("\\n", "⏎", noms)
- noms <- gsub("\\t", "⭾", noms)
-
- Map(cat, types, noms, "\n") -> nul
- }
- }
-
- object_content(irg)
- object_content(irg[["data"]])
- object_content(irg[["data"]][[1]])
-
- search() "package:zzz"
-
- list_packages <- function()
- printdfleft(data.frame(packages = gsub("^package:", "",
- Filter(function(x) grepl("^package:", x),
- search()))))
-
- list_packages()
-
- objects("package:zzz")
- class("package::zzz")
-
- objects("package:dplyr")
-
- detach("package:zzz")
- help("package:zzz")
- help("zzz::fun")
|