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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1743433796, '18.191.160.52', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/languages/R/functions/cat(88): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78