Next: nrows() Up: MacAnova Help File Previous: next   Contents


This topic has information on" notes" attached to variables.
Functions for working with such notes are:
  attachnotes(x, Notes) # attach Notes to x
  attachnotes(x, NULL)  # remove notes from x
  notes <- getnotes(x)  # retrieve notes from x
  if (hasnotes(x)){ something with notes...}
  y <- vector(x, notes:Notes) # create vector with notes Notes
  y <- matrix(x, notes:Notes) # create matrix with notes Notes
  y <- array(x, notes:Notes)  # create array with notes Notes
  plot(x,y [,... ],notes:Notes)     # Notes attached to LASTPLOT
  chplot(x,y,symbols:ch [,...],notes:Notes) # Notes attached to LASTPLOT
  lineplot(x,y [,...], notes:Notes) # Notes attached to LASTPLOT
  showplot([...,] notes:Notes)      # Notes attached to LASTPLOT

Keywords: general, macros, variables
You can attach CHARACTER vectors as "notes" to almost any variable,
including GRAPH variables and macros.  These can be used to record
descriptions of data or plots or usage notes for macros.

When x is an existing variable

  Cmd> attachnotes(x, vector("Heights of Stat 1001 students",\
     "collected Fall 1997"))

attaches the descriptions to variable x.

You can append additional notes to a variable using appendnotes():

  Cmd> appendnotes(x, "There were 29 women and 21 men")

You retrieve notes from a variable by, for example,

  Cmd> getnotes(x)
  (1) "Heights of Stat 1001 students"
  (2) "collected Fall 1997"
  (3) "There were 29 women and 21 men"

One useful trick is to use inforead() to retrieve the comment lines
associated with a data set in a file readable by matread() (see
topics 'matread_file' and inforead()) and then use attachnotes() to
attach them to the matrix:

  Cmd> y <- matread("macanova.dat", "irisdata", quiet:T)

  Cmd> attachnotes(y, inforead("macanova.dat", "irisdata", quiet:T))

You can also attach notes using keyword phrase 'notes:Notes' on
vector(), matrix(), array(), structure(), macro() or any of the plotting
commands, where Notes is a CHARACTER scalar or vector.  For example,

  Cmd> x <- array(x, notes:Notes) # Notes a CHARACTER vector

  Cmd> plot(x, y, notes:"Plot of height vs weight")

Commands matprint(), matwrite() and macrowrite() automatically write any
attached notes in a form that is readable by read(), matread() and
macroread().  See topic 'matread_file'

Generally notes do not "propagate" except in a few situations when the
result of a function is essentially the same as an argument to that
function.  Here are the specific situations when a copy of any notes
attached to x is attached to y.
    y <- x
    y <- vector(x [,labels:Labels]), when isvector(x) is True
    y <- matrix(x [,labels:Labels]), when ismatrix(x) is True
    y <- matrix(x, nrows(x) [,labels:Labels]), when ismatrix(x) is True
    y <- array(x, [,labels:Labels])
    y <- array(x,dim1,dim2,.. [labels:Labels]), when all the new
         dimensions match those of x
    y <- strconcat(x [,labels:Labels] [,compnames:Names]) when
         x is a structure.

See also topics attachnotes(), getnotes(), appendnotes(), vector(),
matrix(), array(), structure(), macro(), 'graph_keys'.

Gary Oehlert 2003-01-15