| cat | R Documentation |
Outputs the objects, concatenating the representations.catperforms much less conversion thanprint.
cat(... , file = "", sep = " ", fill = FALSE, labels = NULL, append = FALSE)
... | R objects (see ‘Details’ for the types of objectsallowed). |
file | A connection, or a character string naming the fileto print to. If |
sep | a character vector of strings to append after each element. |
fill | a logical or (positive) numeric controlling how the output isbroken into successive lines. If |
labels | character vector of labels for the lines printed.Ignored if |
append | logical. Only used if the argument |
cat is useful for producing output in user-defined functions.It converts its arguments to character vectors, concatenatesthem to a single character vector, appends the givensep =string(s) to each element and then outputs them.
No linefeeds are output unless explicitly requested by"\n"or if generated by filling (if argumentfill isTRUE ornumeric).
Iffile is a connection and open for writing it is written fromits current position. If it is not open, it is opened for theduration of the call in"wt" mode and then closed again.
Currently only atomic vectors and names are handled,together withNULL and other zero-length objects (which produceno output). Character strings are output ‘as is’ (unlikeprint.default which escapes non-printable characters andbackslash — useencodeString if you want to outputencoded strings usingcat). Other types ofR object should beconverted (e.g., byas.character orformat)before being passed tocat. That includes factors, which areoutput as integer vectors.
cat converts numeric/complex elements in the same way asprint (and not in the same way asas.characterwhich is used by the S equivalent), sooptions"digits" and"scipen" are relevant. However, it usesthe minimum field width necessary for each element, rather than thesame field width for all elements.
None (invisibleNULL).
If any element ofsep contains a newline character, it istreated as a vector of terminators rather than separators, an elementbeing output after every vector elementand a newline after thelast. Entries are recycled as needed.
Becker, R. A., Chambers, J. M. and Wilks, A. R. (1988)The New S Language.Wadsworth & Brooks/Cole.
print,format, andpastewhich concatenates into a string.
iter <- stats::rpois(1, lambda = 10)## print an informative messagecat("iteration = ", iter <- iter + 1, "\n")## 'fill' and label lines:cat(paste(letters, 100* 1:26), fill = TRUE, labels = paste0("{", 1:10, "}:"))Add the following code to your website.
For more information on customizing the embed code, readEmbedding Snippets.