cat
Print the Arguments

Description

Coerces arguments to mode character, and then prints them to standard output, or to a specified file or connection.

Usage

cat(..., file = "", sep = " ", fill = FALSE, labels = NULL, 
     append = FALSE)

Arguments

... any S objects. The objects are coerced to character data and printed, using the other arguments to control the output. All the elements of the first object are printed, and then all the elements of the second, and so on.
file a string containing the file name or a connection to which to print. If file is "" (the default), cat prints to the standard output.
sep a vector of character strings to insert between successive data items of each object. This argument is used cyclically. The first element of this vector is used to separate different ... objects.
fill a positive numeric or a logical value. Specifies if the output should be broken automatically into successive lines, with newline characters added after each line.
  • If numeric, the value of fill controls the width of the printing. A newline is placed before the first string that makes the present line exceed fill characters.
  • If TRUE, the width option controls the width of the printing, and a newline is placed before the first string that makes the present line exceed fill characters.
  • If FALSE (the default), no newline characters are printed unless some are specified within the ... or sep arguments.
labels a vector of character strings to be used as labels at the start of each line. The labels are used cyclically if there fewer than the number of lines. This argument is relevant only if fill is TRUE or non-zero.
append a logical flag. If TRUE, the output is appended to file. If FALSE (the default), output overwrites the contents of file.

Details

The output contains a final newline if the sep argument contains a newline, or if the fill argument is numeric or TRUE.
cat prints each numeric value to as many digits as needed to represent it. (Use format to control the formatting of numeric values.)
If file is a connection, cat will convert characters to the connection's character encoding (see file). If file is a file name, the default character encoding options("encoding") is used.
Side Effects
either the objects are printed, or file is created or appended.
Note
cat is not designed to produce a full description of arbitrary objects. If you want to do this, use dput or dump. To get output as the engine ordinarily prints it, use the print function.
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. 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").
See Also
factor, format, options, print, paste, file, Syntax.
Examples
x <- 42
cat("current x:", x, "\n")
# current x: 42

cat(LETTERS[1:10], "\n", sep="!") # A!B!C!D!E!F!G!H!I!J!

cat(LETTERS[1:10], "\n", sep="!", fill=6) # A!B!C! # D!E!F! # G!H!I! # J!

cat(1:10, fill=8, labels=letters[1:3]) # a 1 2 3 # b 4 5 6 # c 7 8 9 # a 10

cat(LETTERS[1:3], LETTERS[4:6], sep=letters, fill=30) # AaBbCaDdEeF

Package base version 6.0.0-69
Package Index