spine                  package:vcd                  R Documentation

_S_p_i_n_e _P_l_o_t_s _a_n_d _S_p_i_n_o_g_r_a_m_s

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

     Spine plots are a special cases of mosaic plots, and can be seen
     as a generalization of stacked (or highlighted) bar plots.
     Analogously, spinograms are an extension of histograms.

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

     spine(x, ...)
     ## Default S3 method:
     spine(x, y = NULL,
       breaks = NULL, ylab_tol = 0.05, off = NULL,
       main = "", xlab = NULL, ylab = NULL, margins = c(5.1, 4.1, 4.1, 3.1),
       gp = gpar(), name = "spineplot", newpage = TRUE, pop = TRUE,
       ...)
     ## S3 method for class 'formula':
     spine(formula, data = list(),
       breaks = NULL, ylab_tol = 0.05, off = NULL,
       main = "", xlab = NULL, ylab = NULL, margins = c(5.1, 4.1, 4.1, 3.1),
       gp = gpar(), name = "spineplot", newpage = TRUE, pop = TRUE,
       ...)

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

       x: an object, the default method expects either a single
          variable (interpreted to be the explanatory variable) or a
          2-way table. See details.

       y: a '"factor"' interpreted to be the dependent variable

 formula: a '"formula"' of type 'y ~ x' with a single dependent
          '"factor"' and a single explanatory variable.

    data: an optional data frame.

  breaks: if the explantory variable is numeric, this controls how it
          is discretized. 'breaks' is passed to 'hist' and can be a
          list of arguments.

ylab_tol: convenience tolerance parameter for y-axis annotation. If the
          distance between two labels drops under this threshold, they
          are plotted equidistantly.

     off: vertical offset between the bars (in per cent). It is fixed
          to '0' for spinograms and defaults to '2' for spine plots.

main, xlab, ylab: character strings for annotation

 margins: margins when calling 'plotViewport'

      gp: a '"gpar"' object controlling the grid graphical parameters
          of the rectangles. It should specify in particular a vector
          of 'fill' colors of the same length as 'levels(y)'. The
          default is to call 'gray.colors'.

    name: name of the plotting viewport.

 newpage: logical. Should 'grid.newpage' be called  before plotting?

     pop: logical. Should the viewport created be popped?

     ...: additional arguments passed to 'plotViewport'.

_D_e_t_a_i_l_s:

     'spine' creates either a spinogram or a spine plot. It can be
     called via 'spine(x, y)' or 'spine(y ~ x)' where 'y' is
     interpreted to be the dependent variable (and has to be
     categorical) and 'x' the explanatory variable. 'x' can be either
     categorical (then a spine plot is created) or numerical (then a
     spinogram is plotted). Additionally, 'spine' can also be called
     with only a single argument which then has to be a 2-way table,
     interpreted to correspond to 'table(x, y)'.

     Spine plots are a generalization of stacked bar plots where not
     the heights but the widths of the bars corresponds to the relative
     frequencies of 'x'. The heights of the bars then correspond to the
     conditional relative frequencies of 'y' in every 'x' group. This
     is a special case of a mosaic plot with specific spacing and
     shading.

     Analogously, spinograms extend stacked histograms. As for the
     histogram, 'x' is first discretized (using 'hist') and then for
     the discretized data a spine plot is created.

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

     The table visualized is returned invisibly.

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

     Achim Zeileis Achim.Zeileis@R-project.org

_R_e_f_e_r_e_n_c_e_s:

     Hummel, J. (1996), Linked bar charts: Analysing categorical data
     graphically. _Computational Statistics_, *11*, 23-33.

     Hofmann, H., Theus, M. (2005), _Interactive graphics for
     visualizing conditional distributions_, Unpublished Manuscript.

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

     'cd_plot', 'mosaic', 'hist'

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

     ## Arthritis data (dependence on a categorical variable)
     data("Arthritis")
     (spine(Improved ~ Treatment, data = Arthritis))

     ## Arthritis data (dependence on a numerical variable)
     (spine(Improved ~ Age, data = Arthritis, breaks = 5))
     (spine(Improved ~ Age, data = Arthritis, breaks = quantile(Arthritis$Age)))
     (spine(Improved ~ Age, data = Arthritis, breaks = "Scott"))

     ## Space shuttle data (dependence on a numerical variable)
     data("SpaceShuttle")
     (spine(Fail ~ Temperature, data = SpaceShuttle, breaks = 3))

