str                  package:utils                  R Documentation

_C_o_m_p_a_c_t_l_y _D_i_s_p_l_a_y _t_h_e _S_t_r_u_c_t_u_r_e _o_f _a_n _A_r_b_i_t_r_a_r_y _R _O_b_j_e_c_t

_D_e_s_c_r_i_p_t_i_o_n:

     Compactly display the internal *str*ucture of an R object, a
     "diagnostic" function and an alternative to 'summary' (and to some
     extent, 'dput').  Ideally, only one line for each "basic"
     structure is displayed.  It is especially well suited to compactly
     display the (abbreviated) contents of (possibly nested) lists. 
     The idea is to give reasonable output for *any* R object.  It
     calls 'args' for (non-primitive) function objects.

_U_s_a_g_e:

     str(object, ...)

     ## S3 method for class 'data.frame':
     str(object, ...)

     ## Default S3 method:
     str(object, max.level = NA, vec.len = 4, digits.d = 3,
         nchar.max = 128, give.attr = TRUE, give.length = TRUE,
         wid = getOption("width"), nest.lev = 0,
         indent.str = paste(rep.int(" ", max(0, nest.lev + 1)), collapse = ".."),
         comp.str="$ ", no.list = FALSE, envir = NULL,
         ...)

_A_r_g_u_m_e_n_t_s:

  object: any R object about which you want to have some information.

max.level: maximal level of nesting which is applied for displaying
          nested structures, e.g., a list containing sub lists. Default
          NA: Display all nesting levels.

 vec.len: numeric (>= 0) indicating how many "first few" elements are
          displayed of each vector.  The number is multiplied by
          different factors (from .5 to 3) depending on the kind of
          vector.  Default 4.

digits.d: number of digits for numerical components (as for 'print').

nchar.max: maximal number of characters to show for 'character'
          strings.  Longer strings are truncated, see 'longch' example
          below.

give.attr: logical; if 'TRUE' (default), show attributes as sub
          structures.

give.length: logical; if 'TRUE' (default), indicate length (as
          '[1:...]').

     wid: the page width to be used.  The default is the currently
          active 'options("width")'.

nest.lev: current nesting level in the recursive calls to 'str'.

indent.str: the indentation string to use.

comp.str: string to be used for separating list components.

 no.list: logical; if true, no "list of .." is nor the class is
          printed.

   envir: the environment to be used for _promise_ (see
          'delayedAssign') objects only.

     ...: potential further arguments (required for Method/Generic
          reasons).

_V_a_l_u_e:

     'str' does not return anything, for efficiency reasons. The
     obvious side effect is output to the terminal.

_A_u_t_h_o_r(_s):

     Martin Maechler maechler@stat.math.ethz.ch since 1990.

_S_e_e _A_l_s_o:

     'ls.str' for _listing_ objects with their structure; 'summary',
     'args'.

_E_x_a_m_p_l_e_s:

     require(stats)
     ## The following examples show some of 'str' capabilities
     str(1:12)
     str(ls)
     str(args) #- more useful than  args(args) !
     str(freeny)
     str(str)
     str(.Machine, digits = 20)
     str( lsfit(1:9,1:9))
     str( lsfit(1:9,1:9),  max = 1)
     op <- options(); str(op) #- save first; otherwise internal options() is used.
     need.dev <- !exists(".Device") || is.null(.Device)
     if(need.dev) postscript()
     str(par()); if(need.dev) graphics.off()

     ch <- letters[1:12]; is.na(ch) <- 3:5
     str(ch) # character NA's

     nchar(longch <- paste(rep(letters,100), collapse=""))
     str(longch)
     str(longch, nchar.max = 52)


     str(quote( { A+B; list(C,D) } ))


     ## S4 classes :
     require(stats4)
     x <- 0:10; y <- c(26, 17, 13, 12, 20, 5, 9, 8, 5, 4, 8)
     ll <- function(ymax=15, xh=6) -sum(dpois(y, lambda=ymax/(1+x/xh), log=TRUE))
     fit <- mle(ll)
     str(fit)

