Misc                  package:Hmisc                  R Documentation

_M_i_s_c_e_l_l_a_n_e_o_u_s _F_u_n_c_t_i_o_n_s

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

     This documents miscellaneous small functions in Hmisc that may be
     of interest to users.

     'clowess' runs 'lowess' but if the 'iter' argument exceeds zero,
     sometimes wild values can result, in which case 'lowess' is re-run
     with 'iter=0'.

     'confbar' draws multi-level confidence bars using small rectangles
     that may be of different colors.

     'getLatestSource' fetches and 'source's the most recent source
     code for functions in packages in the Vanderbilty University CVS
     repository.

     'james.stein' computes James-Stein shrunken estimates of cell
     means given a response variable (which may be binary) and a
     grouping indicator.

     'km.quick' provides a fast way to invoke 'survfit.km' in the
     'survival' package to get Kaplan-Meier estimates for a single
     stratum for a vector of time points (if 'times' is given) or to
     get a vector of survival time quantiles (if 'q' is given).

     'lm.fit.qr.bare' is a fast stripped-down function for computing
     regression coefficients, residuals, R^2, and fitted values.  It
     uses the Fortran routines 'dqrls'. 

     'matxv' multiplies a matrix by a vector, handling automatic
     addition of intercepts if the matrix does not have a column of
     ones. If the first argument is not a matrix, it will be converted
     to one.

     'nomiss' returns a data frame (if its argument is one) with rows
     corresponding to 'NA's removed, or it returns a matrix with rows
     with any element missing removed.

     'outerText' uses 'text()' to put test strings in left or right
     margins. It temporarily sets 'par(xpd=NA)' if using R.

     'sepUnitsTrans' converts character vectors containing values such
     as 'c("3 days","3day","4month","2 years","2weeks","7")' to numeric
     vectors  (here 'c(3,3,122,730,14,7)') in a flexible fashion.  The
     user can specify a  vector of units of measurements and conversion
     factors.  The units with a conversion factor of '1' are taken as
     the target units, and if those units are present in the character
     strings they are ignored.  The target units are added to the
     resulting vector as the '"units"' attribute.

     'trap.rule' computes the area under a curve using the trapezoidal
     rule, assuming 'x' is sorted.

     'trellis.strip.blank' sets up Trellis or Lattice graphs to have a
     clear background on the strips for panel labels.

     'under.unix' is a scalar logical value that is 'TRUE' if you are
     running Linux or Unix.

     '.R.' is a logical value set to 'TRUE' if running R, 'FALSE' for
     S-Plus.

     '.SV4.' is a logical value set to 'TRUE' if running version 4 of
     the S language under S-Plus, 'FALSE' otherwise.

     'unPaste' provides a version of the S-Plus 'unpaste' that works
     for R and S-Plus.

     'whichClosePW' is a very fast function using weighted multinomial
     sampling to determine which element of a vector is "closest" to
     each element of another vector.  'whichClosest' quickly finds the
     closest element without any randomness.

     'xless' is a function for Linux/Unix users to invoke the system
     'xless' command to pop up a window to display the result of
     'print'ing an object.  For Windows, 'xless' uses the builtin
     'page' function but with better defaults.

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

     confbar(at, est, se, width, q = c(0.7, 0.8, 0.9, 0.95, 0.99), 
             col = if (.R.) gray(c(0, 0.25, 0.5, 0.75, 1)) else
                   if (under.unix) c(1, 0.8, 0.5, 0.2, 0.065) else
                   c(1, 4, 3, 2, 5),
             type = c("v", "h"), labels = TRUE, ticks = FALSE,
             cex = 0.5, side = "l", lwd = 5, clip = c(-1e+30, 1e+30),
             fun = function(x) x,
             qfun = function(x) ifelse(x == 0.5, qnorm(x),
                                 ifelse(x < 0.5, qnorm(x/2),
                                 qnorm((1 +  x)/2))))
     getLatestSource(x=NULL, package='Hmisc', recent=NULL, avail=FALSE) 
     james.stein(y, group)
     km.quick(S, times, q)
     lm.fit.qr.bare(x, y, tolerance, intercept=TRUE, xpxi=FALSE)
     matxv(a, b, kint=1)
     nomiss(x)
     outerText(string, y, setAside=string[1], side=4, space=1,
               adj=1, cex=par('cex'))
     sepUnitsTrans(x, conversion=c(day=1, month=365.25/12, year=365.25, week=7),
                   round=FALSE, digits=0)
     trap.rule(x, y)
     trellis.strip.blank()
     unPaste(str, sep="/", extended=FALSE)
     whichClosest(x, w)
     whichClosePW(x, w, f=0.2)
     xless(x, ..., title)

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

       a: a numeric matrix or vector

     adj: 0 for left justification, 0.5 for centered, 1 for right

      at: x-coordinate for vertical confidence intervals, y-coordinate
          for horizontal

   avail: set to 'TRUE' to have 'getLatestSource' return a data frame
          of available files and latest versions instead of fetching
          any

       b: a numeric vector

     cex: character expansion factor

    clip: interval to truncate limits

     col: vector of colors

conversion: a named numeric vector

  digits: number of digits used for 'round'

     est: vector of point estimates for confidence limits

extended: see 'strsplit' in R

       f: a scaling constant

     fun: function to transform scale

   group: a categorical grouping variable

intercept: set to 'FALSE' to not automatically add a column of ones to
          the 'x' matrix

    kint: which element of 'b' to add to the result if 'a' does not
          contain a column for intercepts

  labels: set to 'FALSE' to omit drawing confidence coefficients

     lwd: line widths

 package: name of package for 'getLatestSource', default is ''Hmisc''

       q: vector of confidence coefficients or quantiles

    qfun: quantiles on transformed scale

  recent: an integer telling 'getLatestSource' to get the 'recent' most
          recently modified files from the package

   round: set to 'TRUE' to round converted values

       S: a 'Surv' object

      se: vector of standard errors

     sep: a single character string specifying the delimiter

setAside: for 'adj=1 side=4', is a character string used to determine
          the space to set aside for all strings.

    side: for 'confbar' is '"b","l","t","r"' for bottom, left, top,
          right.  For 'outText' is the using integers 1-4 corresponding
          to these.

   space: the number of extra characters to leave to the left of the
          string(s) ('adj=0') or to the right ('adj=1')

     str: a character string vector

  string: a character string vector

   ticks: set to 'TRUE' to draw lines between rectangles

   times: a numeric vector of times

   title: a character string to title a window or plot

tolerance: tolerance for judging singularity in matrix

    type: '"v"' for vertical, '"h"' for horizontal

       w: a numeric vector

   width: width of confidence rectanges in user units

       x: a numeric vector (matrix for 'lm.fit.qr.bare') or data frame.
           For 'xless' may be any object that is sensible to 'print'. 
          For 'sepUnitsTrans' is a character or factor variable.  For
          'getLatestSource' is a character string or vector of
          character strings containing base file names to retrieve from
          CVS.  Set 'x='all'' to retrieve all source files.  For
          'clowess', 'x' may also be a list with x and y components.

    xpxi: set to 'TRUE' to add an element to the result containing the
          inverse of X'X

       y: a numeric vector

     ...: arguments passed through to another function

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

     Frank Harrell

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

     trap.rule(1:100,1:100)

     unPaste(c('a;b or c','ab;d','qr;s'), ';')

     sepUnitsTrans(c('3 days','4 months','2 years','7'))

     set.seed(1)
     whichClosest(1:100, 3:5)
     whichClosest(1:100, rep(3,20))

     whichClosePW(1:100, rep(3,20))
     whichClosePW(1:100, rep(3,20), f=.05)
     whichClosePW(1:100, rep(3,20), f=1e-10)

     ## Not run: 
     getLatestSource(recent=5)  # source() most recent 5 revised files in Hmisc
     getLatestSource('cut2')    # fetch and source latest cut2.s
     getLatestSource('all')     # get everything
     getLatestSource(avail=TRUE) # list available files and latest versions
     ## End(Not run)

