# Generic function: str(object, ...) ## Default S3 method: str(object, max.level = NA, vec.len = strO$vec.len, digits.d = strO$digits.d, nchar.max = 128, give.attr = TRUE, give.head = TRUE, give.length = give.head, width = getOption("width"), nest.lev = 0, indent.str = paste(rep.int(" ", max(0, nest.lev + 1)), collapse = ".."), comp.str = "$ ", no.list = FALSE, envir = baseenv(), strict.width = strO$strict.width, formatNum = strO$formatNum, list.len = 99, ...)strOptions(strict.width = "no", digits.d = 3, vec.len = 4, formatNum = function(x, ...) format(x, trim = TRUE, drop0trailing = TRUE, ...))
object | any object whose structure is displayed compactly. | ||||||
max.level | maximal level of a nesting structure can be displayed. The default is NA, which means all levels of a nesting structure are displayed. | ||||||
vec.len | The suggested number of elements in a vector to display. The actual number of displayed elements depends on the data and the width argument. | ||||||
digits.d | the number of significant digits to display in numeric or complex components. The default is the "digits.d" component of option "str". | ||||||
nchar.max | The maximum number of characters to display for a character string. Longer strings are truncated and the string "| __truncated__" is appended to them. | ||||||
give.attr | a logical value. If TRUE (the default), the attribute(s) of the object and of its subcomponents are shown. | ||||||
give.head | a logical value. If TRUE (the default), the class or mode type (which can be abbreviated) and the length (shown in the form of [1:n]) are shown. (The display of length information is dependent on give.length.) | ||||||
give.length | a logical value. If TRUE, the length information (in the form of [1:n]) is shown when give.head is also TRUE. | ||||||
width | the width of the page. This argument is effective only when strict.width is not "no". The default value is defined by the system option "width". | ||||||
nest.lev | the current nesting level. This argument is used in recursive iteration to show all structures. The default is 0, which indicates the root level. | ||||||
indent.str | the string for indentation. The default string is concatenated with several (nest.lev+1) blanks separated with "..". | ||||||
comp.str | the string to separate the components of the list. The default is "$". Note that the string to separate the slots of an S4 object is "@". | ||||||
no.list | a logical value. If TRUE, no "List of [n]" is shown. The default is FALSE. | ||||||
envir | This argument is not yet implemented. The environment to use for "promise" objects. | ||||||
strict.width |
This argument is not yet implemented.
A character string that specifies how to handle lines exceeding the page width.
Can be one of the following three supported strings:
| ||||||
formatNum | This argument is not yet implemented. A format function for a numeric vector. The default value is the "formatNum" component of option "str". | ||||||
list.len | the maximal number of lists to be shown in a level. If the number of the existing list is greater than this maximum, string "[list output truncated]" is appended. | ||||||
... | other arguments pass to or from methods/functions. |
str | returns nothing; it just sends the output to the terminal. |
strOptions | returns a named list of the following options:
|
ldose <- rep(0:5, 2) numdead <- c(1, 4, 9, 13, 18, 20, 0, 2, 6, 10, 12, 16) sex <- factor(rep(c("M", "F"), c(6, 6))) SF <- cbind(numdead, numalive = 20 - numdead) x <- glm(SF ~ sex*ldose, family = binomial) str(x) str(x, max.level = 2, digits.d = 5, strict.width = "wrap") str(x, give.attr = FALSE, give.head = FALSE, give.length = TRUE) str(x, no.list = TRUE, list.len = 6, nchar.max = 3, comp.str = "#")str(substitute(x)) str(factor) # factor is a function. str(Sdatasets::co2) # co2 is a Time-Series object. str(Sdatasets::air) # air is a data frame str(cbind2) # cbind2 is an S4 object.
# Example for a "call" object. funs <- c("sin", "cos") xx <- 30*pi/180 ii <- 1 my.call <- call(funs[ii], as.name("xx")) str(my.call)
# Example for "strOptions". oldOptions <- options(str = strOptions(strict.width = "wrap", digits.d = 4, vec.len = 5 )) str(options()) options(oldOptions)