Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Print multiple lines without printing the print()

Tags:

r

printing

I want to print a summary table(self-formatted) in R. So These summaries contain multiple lines and I'm working with RStudio and RScripts. So if I execute a statement like this:

print("Line 1")
print("Line 2")

I would like to have an output like

Line 1
Line 2

Instead I'm getting

> print("Line 1")
[1] "Line 1"
> print("Line 2")
[1] "Line 2"

What method could help or what do I have to do to achieve the desired output?

like image 864
MichiZH Avatar asked Jan 13 '23 15:01

MichiZH


1 Answers

This will do what you are looking for cat("Line 1 \nLine 2")

 >cat("Line 1 \nLine 2")
 Line 1 
 Line 2

See R - do I need to add explicit new line character with print()?

like image 141
TylerDurden Avatar answered Jan 22 '23 03:01

TylerDurden