Dd Pp
Dd Pp

Reputation: 5977

adjust gap between the lines in R console

When I parse web sites in R, (system: R+debian) the html object output in the console make me uncomfortable.

The gap is wide between lines. How can I make it normal, to narrow the gap between the lines?

Maybe you can see tha same output with the following code.

options(encoding="gbk")
library(XML)
baseURL <- "http://www.jb51.net/article/27174.htm"
txt <- readLines(baseURL)
txt

enter image description here

Upvotes: 0

Views: 1019

Answers (2)

flodel
flodel

Reputation: 89067

Interesting, it seems that when print-ing a vector, the longest element decides how all elements will be spaced.

Your longest string is txt[374]: on my screen, it takes 19 lines; that means every element of txt will be printed using 19 lines, with possibly a lot of white space.

You don't have that problem when printing a list, so a solution is to do:

print(as.list(txt))

Upvotes: 1

Alan
Alan

Reputation: 3203

Try to use gsub() for replacing space by nothing.

Upvotes: 0

Related Questions