문제

enter image description here

I have a data.frame in which a column has multiple lines of text. How can I wrap the text to print the data frame using grid.draw ? I tried using strwrap but no luck.

A=data.frame(name=c("ABC","XYZ","DEF"),description=c(rep("This is an example for text wrap using grid.draw in package gridExtra",3))
도움이 되었습니까?

해결책

Use package gridExtra which has a function grid.table, and add \n into your data frame where you want the breaks:

A=data.frame(name=c("ABC","XYZ","DEF"),description=c(rep("This is an example for text wrap \nusing grid.draw in package gridExtra",3))
grid.newpage()
grid.table(A)

You can tune up the table pretty nicely using the various arguments.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top