Next: plot() Up: MacAnova Help File Previous: partacf()   Contents


paste(arg1, arg2, ... [,format:Fmt,sep:C,intwidth:Iw,charwidth:Cw,\
  missing:S]), Fmt, C, and S CHARACTER scalars, Iw and Cw integers > 0
paste(arg,multiline:T [,format:Fmt,sep:Cs,linesep:Cl,missing:S]), where
  Cs and Cl are CHARACTER scalars consisting of a single character.
'iw', 'cw', 'fmt', and 'just' are synonyms for 'intwidth', 'charwidth',
  'format' and 'justify'

Keywords: output, missing values
paste(arg1, arg2, ...) returns a CHARACTER scalar concatenating the
arguments.  For example, the value of
    paste("The answer is", run(7), "; ok?")
is the string "The answer is 1 2 3 4 5 6 7 ; ok?" .

An important use of paste() is in constructing labels for graphs (for
example, title:paste("Variable",j,"vs variable",i)).  It is also useful
for producing informative messages to be printed in a macro and can be
used to prepare nicely formatted lines for output.

The default behavior is to print the arguments separated by single
spaces, with exact integers printed as such, non-integers printed using
the default print format (see print(), subtopi 'options:"format"') with
leading spaces trimmed off, and missing values printed as "MISSING".  If
you have used setoptions() to replace "MISSING" by a different default
string, the replacement will be used.

A NULL non-keyword argument is ignored unless it is the only argument,
in which case paste(NULL) returns "".

paste(arg1, arg2, ..., sep:S), where S is a CHARACTER variable or quoted
string, uses S to separate arguments rather than a space.  For example,
paste(run(5),sep:",") produces the string "1,2,3,4,5" and
paste("A","B","C","D","E",sep:"") produces the string "ABCDE".  No
separator is ever put before the first item in the output variable.  You
can have several instances of 'sep:S' with different separators, each
affecting later arguments until changed.

paste(arg1, arg2, ..., intwidth:w), where w is a positive integer prints
each exact integer using at least w positions, padding on the left with
spaces if necessary.  For example, paste(12,intwidth:5) produces " 12".
You can use iw:w instead of intwidth:w.

paste(arg1, arg2, ..., format:Fmt), where Fmt is a CHARACTER variable or
quoted string representing either a f-format ("10.5f" or "f10.5") or
g-format ("11.7g" or "g11.7") (see print()) prints any non-integer REALs
using format Fmt If the width is omitted (".7f") leading spaces will be
stripped off.  If the width is not omitted ("10.7f"), any non-integer
REAL variables printed will be formatted so as to use at least this
width.  If 'intwidth:w' has not previously appeared, this width will
also be used for integers.  You can use fmt:Fmt instead of format:Fmt.

paste(arg1, arg2, ..., charwidth:w), w is a positive integer, uses at
least w character positions for any CHARACTER argument, padding on the
right with spaces if necessary, unless justify:"r" or justify:"c" is an
argument.  You can use cw:w instead of charwidth:w.

paste(arg1, arg2, ..., justify:C), where C is "right", "left", or
"center" (or simply "r", "l", or "c"), specifies that any strings are to
be right justified, left justified or centered, respectively.  This has
no effect unless charwidth:w is specified and a string is shorter than
w.  The default is justify:"left".  You can use just:C instead of

paste(arg1, arg2, ..., missing:String), where String is a quoted string
or CHARACTER scalar such as "?", uses String to represent a missing
value instead of "MISSING".  If a format has been specified with width >
0 longer than the length of String, String will be padded on the left to
make it have this width.

You can use any of the keywords more than once anywhere in the argument
list, with each usage affecting the formatting of subsequent items until
changed by a new keyword phrase.  Putting it after all non-keyword
arguments, as illustrated above, is equivalent to putting it before
them.  For example, paste(sep:",",charwidth:5,a,b,c) is equivalent to
paste(a,b,c,sep:",", charwidth:5).

paste(arg,multiline:T) has somewhat different behavior.  The result is
much as before, except, if arg is other than a row vector, the result is
a CHARACTER vector, with one element for each value of the first
dimension that is greater than 1.  Thus, if arg is a matrix or vector,
each element of the output is a character representation of a row of
arg. When you use 'multiline:T', there must be exactly 1 non-keyword
argument.  If arg is LOGICAL, it is first translated to REAL with True
and False becoming 1 and 0, respectively.  If arg is NULL, the result is

paste(arg,multiline:T,linesep:Char), where Char is a string with just
one character such as ";" or "\n" (the end-of-line character), combines
the rows into a single CHARACTER scalar with each row separated by Char.
If arg is a row vector (just 1 row), Char is ignored.

Along with 'multiline:T', you can use keywords 'sep', 'format', and
'missing', but not 'intwidth' and 'charwidth'.  If it appears, the value
for 'sep' must be a string with just one character, for example, " "
(the default) or "\t".  Any leading or trailing blanks in each numerical
field are trimmed off when 'sep' is used.

Function paste() does not recognize keyword 'nsig'.

  Cmd> paste(sep:"-","tick","tock",sep:", ","ding",sep:"-","dong")
  (1) "tick-tock, ding-dong"

The first 'sep:"-"' could also come at the end.

  Cmd> paste("PI is",PI,format:".10f") # or "Pi is",PI,fmt:".10f"
  (1) "PI is 3.1415926536"

  Cmd> paste(format:"10.2f",sqrt(2),format:".15g",sqrt(2))
  (1) "      1.41 1.4142135623731"

  Cmd> paste("Blocks",DF[2],SS[2],SS[2]/DF[2],format:"7.3f",\
  (1) "Blocks    4       48.0368       12.0092  18.782"

In the preceding, 'cw', 'iw', and 'fmt' could replace 'charwidth',
'intwidth' and 'format'.

  Cmd> paste(x, multiline:T) # 3 by 5 matrix x
  (1) "10.322 9.5278 10.636 10.411 9.6343"
  (2) "9.9979 10.606 8.1604 MISSING 8.5926"
  (3) "8.6147 11.212 9.4683 7.7964 10.489"

  Cmd> paste(x,multiline:T,linesep:"\n",sep:",",\
  (1) "10.3222,9.5278,10.6357,10.4106,9.6343

See also print().

Gary Oehlert 2003-01-15