How to use cat() function In R Language
In this method, the need to call the cat() function which is here responsible to print text and text.
Syntax: cat(text/file = “”, sep = ” “, fill = FALSE, labels = NULL, append = FALSE)
Parameters:
- Text/file: text or file you want to print.
- sep: separator
- fill: If fill=TRUE, a new line will be printed if page is filled.
- labels: labels if any
R
# storing strings in variables string1 <- "GEEKS" string2 <- "FOR" string3 <- "GEEKS" # passing variable in cat() without new # line serperator cat (string1,string2,string3) # passing a string using \n to split cat ( "GEEKS \nFOR \nGEEKS" ) # passing variables using \n cat (string1, "\n" ,string2, "\n" ,string3) |
Output:
GEEKS FOR GEEKS
GEEKS
FOR
GEEKS
GEEKS
FOR
GEEKS
R Program to Print a New Line in String
In this article, we will discuss how to print a new line in a string using R Programming Language.
Contact Us