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")
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");
Printing text to stderr
The
file
argument can be used to redirect text to
stderr.
cat(file = stderr(), "Error: something weird has happedn\n");