Printing multiple lines without printing printing ()

I want to print a pivot table (self-formatted) in R. So, these summaries contain a few lines, and I work with RStudio and RScripts. Therefore, if I execute an operator like this:

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

I would like to have a way out like

 Line 1 Line 2 

Instead i get

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

Which method can help or what do I need to do to achieve the desired result?

+4
source share
2 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 an explicit newline character using print ()?

+6
source

I think the easiest way is

 dataframe[1:2,] 

where dataframe = name of your dataset (assuming you are using tabular data).

In this case, you print the first two rows and all columns (leaving the second element in the vector blank).

0
source

Source: https://habr.com/ru/post/1497180/


All Articles