contents                package:Hmisc                R Documentation

_M_e_t_a_d_a_t_a _f_o_r _a _D_a_t_a _F_r_a_m_e

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

     'contents' is a generic method for which 'contents.data.frame' is
     currently the only method.  'contents.data.frame' creates an
     object containing the following attributes of the variables  from
     a data frame: names, labels (if any), units (if any), number of
     factor levels (if any), factor levels, class, storage mode, and
     number of NAs.  'print.contents.data.frame' will print the
     results, with options for sorting the variables.
     'html.contents.data.frame' creates HTML code for displaying the
     results.  This code has hyperlinks so that if the user clicks on
     the number of levels the browser jumps to the correct part of a
     table of factor levels for all the 'factor' variables.

     'contents.list' prints a directory of datasets when 'sasxport.get'
     imported more than one SAS dataset.

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

     contents(object, ...)
     ## S3 method for class 'data.frame':
     contents(object, ...)
     ## S3 method for class 'contents.data.frame':
     print(x,
         sort=c('none','names','labels','NAs'), prlevels=TRUE, ...) 
     ## S3 method for class 'contents.data.frame':
     html(object,  sort=c('none','names','labels','NAs'), prlevels=TRUE,
                file=paste('contents',object$dfname,'html',sep='.'),
                append=FALSE, ...)
     ## S3 method for class 'list':
     contents(object, dslabels, ...)
     ## S3 method for class 'contents.list':
     print(x,
         sort=c('none','names','labels','NAs','vars'), ...)

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

  object: a data frame.  For 'html' is an object created by 'contents'.
           For 'contents.list' is a list of data frames.

       x: an object created by 'contents'

    sort: Default is to print the variables in their original order in
          the data frame.  Specify one of  '"names"', '"labels"', or
          '"NAs"' to sort the variables by, respectively,
          alphabetically by names, alphabetically by labels, or by
          increaseing order of number of missing values.  For
          'contents.list', 'sort' may also be the value '"vars"' to
          cause sorting by the number of variables in the dataset. 

prlevels: set to 'FALSE' to not print all levels of 'factor' variables 

    file: file to which to write the html code.  Default is
          '"conents.dfname.html"' where 'dfname' is the name of the
          data frame processed by 'contents'.

  append: set to 'TRUE' to add html code to an existing file

     ...: arguments passed from 'html' to 'format.df', unused otherwise

dslabels: named vector of SAS dataset labels, created for example by
          'sasdsLabels'

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

     an object of class '"contents.data.frame"' or '"contents.list"'

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

     Frank Harrell 
      Vanderbilt University 
      f.harrell@vanderbilt.edu

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

     'describe', 'html'

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

     set.seed(1)
     dfr <- data.frame(x=rnorm(400),y=sample(c('male','female'),400,TRUE))
     contents(dfr)
     k <- contents(dfr)
     print(k, sort='names', prlevels=FALSE)
     ## Not run: 
     html(k)
     html(contents(dfr))            # same result
     w <- html(k, file='my.html')   # create my.html, don't display
     ## End(Not run)

