character
and then prints to standard output,
or to a specified file or connection.
cat(..., file=<<see below>>, sep=" ", fill=F, labels=NULL, append=F)
file
is
""
(the default),
cat
prints to the standard output.
fill
controls the width of the printing.
If
TRUE
, the option
width
controls the width of the printing.
fill
is
TRUE
or non-zero.
TRUE
, output will be appended to
file
;
otherwise, output will overwrite the contents of
file
.
file
is created or appended.
When
fill
is
FALSE
, there are no newline characters printed except those
created explicitly with a backslash-n.
Tabs are created with backslash-t and backslashes are printed using a double
backslash.
When
fill
is a positive number, a newline is placed before the first
string that makes the present line exceed
fill
characters.
If present,
labels
is cycled through.
Each label is paired with a character string; so if there were only two
labels and an even number of strings on each line, only the first label
would be printed.
A special case occurs when only one string is given (i.e., one argument
of length one) and
fill = TRUE
.
In this case
cat
will break the string at any internal white space
to avoid overrunning the width of the line.
In other words, if you want to have your output broken at arbitrary
white space, not just between items, first make the output into a single
string (by the function
paste
, for example) and give that string to
cat
with
fill = TRUE
.
Also,
cat
will print each numeric value to as many digits as needed
to represent it.
You might want to use
format
to control the
formatting of numeric values.
cat
is not designed to produce a full description of arbitrary
S-PLUS objects; for this, use
dput
,
dump
or
data.dump
.
To get output as S-PLUS ordinarily prints it, use the
print
function
(and use
sink
to capture this output in a
file).
When using ascii codes in a character string, "\n" and "\t" denote ascii
newline and tab characters, respectively, "\\" denotes a backslash, and
"\"" represents a quote within a string. Some other C escape sequences are
allowed but are not supported. Arbitrary ascii codes may be included by
"\nnn" where
nnn
is a 3-digit number in octal notation (e.g. "\012" is
the same as "\n"). For a list of ascii characters, see help(ascii).
cat("current x:", x, fill=T) cat("Today's date is:",date(),"\n") cat(1,2,3,4,5,6, fill=4, labels=letters[1:6]) cat(rnorm(40), fill=T, labels=c("odd string first","even string first"))
> data.class(fuel.frame$Type) [1] "factor" > cat("one", fuel.frame$Type[13:14], "auto", "\n") one 4 5 auto > cat("one", as.character(fuel.frame$Type[13:14]), "auto", "\n") one Small Sporty auto