Multiline string literal

Basic types / Strings

# A literal keeps line breaks and the indent
multiline_string <- "
    1. First line
    2. Second line
        3. Third line
    4. Fourth \"line\"
    "

# Raw string r"(...)": no escapes needed
raw_string <- r"(
    1. First line
    4. Fourth "line"
    )"

# Cut the common indent
trimmed <- gsub("\n    ", "\n", multiline_string,
                fixed = TRUE)

# Pieces glued with a break
joined <- paste("1. First line", "2. Second line",
                sep = "\n")

# print() shows the line breaks as \n
print(multiline_string)
print(raw_string)
print(trimmed)

# cat() shows them as real breaks
cat(joined, "\n")