Search notes:

R function: cat

cat is kind of a low level version of print.
cat returns NULL.
#  S.a. -> print(),
#          ../examples/printing_characters.R


cat("foo\nbar\nbaz\n")
# foo
# bar
# baz

cat(1:10, sep=",")
# 1,2,3,4,5,6,7,8,9,10

cat("writing to a file", file="written-by-cat.txt")

cat("\n")
file.show("written-by-cat.txt")
Github repository about-r, path: /functions/cat/cat.R

Printing each element of a vector on a separate line

cat combined with sep="\n" prints each element of a vector on its own line:
vec <- c('foo bar baz', 'one two three', 'hello world');

cat(vec, sep="\n");
Github repository about-r, path: /functions/cat/vector-elements-on-separate-line.R
See also printing vectors vertically.

Printing text to stderr

The file argument can be used to redirect text to stderr.
cat(file = stderr(), "Error: something weird has happedn\n");

See also

message, print, writeLines
sprintf
Index to (some) R functions

Index