Ad space (banner)
๐Ÿ“ŠR Lessons
Lesson 46 / 68

Assembling multi-line text

This lesson covers assembling multi-line text with R's paste, with the aim of building readable messages.

Including the newline character while assembling with paste0() produces a message that spans several lines. Use it when one variable needs to hold multi-line text.

The sample code joins a greeting, a thank-you, and a closing line with newlines between them via paste0(), gathers them into a single message variable, and prints it with cat().

A common early stumble is the difference between print() and cat(). Printing with print() can show the newline escaped rather than as an actual line break, so use cat() when you want real line breaks.

In professional work, this comes up whenever multi-line text has to be assembled — report output, message building.

๐Ÿ“– Reference code
โœ๏ธ Your code
Type your code, then press "Run"

๐Ÿงช This site can't compile or run R directly, so it checks on the spot whether what you typed matches the reference code (scoring happens entirely in your browser โ€” nothing is sent anywhere).

Ad space (banner)
Ad space (in-article)