Browse Source

Use identifier instead of name

master
Maxime Wack 3 years ago
parent
commit
5065345778
1 changed files with 11 additions and 11 deletions
  1. +11
    -11
      functions.Rmd

+ 11
- 11
functions.Rmd View File

@@ -24,22 +24,22 @@ get_object <- function(fullname)
## Get name

Get the printing name of an object given its identifier.
Names come in quoted if the object is named, or as an index number.
The return name is unquoted or surrounded with double brackets
Identifiers come in **quoted** if the object is named, or as an **index** number.
The printing name is unquoted or surrounded with double brackets if an index.

```{r get name}
##' Get an object name
##'
##' Return the printing name of an object as given to print_object
##' @title
##' @param object A string with the name of an object within its parent
##' @param identifier An object identifier string
##' @return The name of the object or its index in brackets
get_name <- function(object)
get_name <- function(identifier)
{
if (substr(object, 1, 1) == "\"")
substr(object, 2, nchar(object) - 1)
if (substr(identifier, 1, 1) == "\"")
substr(identifier, 2, nchar(identifier) - 1)
else
paste0("[[", object, "]]")
paste0("[[", identifier, "]]")
}
```
## Get fullname
@@ -169,19 +169,19 @@ print_environment <- function(env)
##' else we construct the fullname by subsetting by name/position
##' Thus the caller needs to build the object name accordingly.
##' @title Print an object
##' @param object The object to print as a quoted string or index position
##' @param identifier The identifier of the object to print
##' @param parent The parent object
##' @return The line to print to the buffer
print_object <- function(object, parent = "")
print_object <- function(identifier, parent = "")
{
full_name <- get_fullname(object, parent)
full_name <- get_fullname(identifier, parent)
type <- get_type(full_name)

paste0(full_name,
"|",
type,
"| ",
get_name(object),
get_name(identifier),
" (",
get_size(full_name, type),
")")


Loading…
Cancel
Save