How to Split R Code Over Multiple Lines in a Script (Example Code)

In this R tutorial you’ll learn how to write long code over several lines.

Example: How to Split a Character String Over Multiple Lines

string_one_line <- "my example string in R"    # One line character string
string_one_line                                # Returning character string
# "my example string in R"
string_multiple_lines <- "my 
example 
string 
in 
R"                                             # Multiple lines character string
string_multiple_lines                          # Returning character string
# "my \nexample \nstring \nin \nR"
cat(string_multiple_lines)                     # Returning character string using cat()
# my 
# example 
# string 
# in 
# R

Leave a Reply

Your email address will not be published. Required fields are marked *

Fill out this field
Fill out this field
Please enter a valid email address.
You need to agree with the terms to proceed

Menu
Top