2017-05-24 3 views
1

Rがデータフレームをコンソールに印刷する方法を調整しようとしています。具体的には、ある幅に達した後に列のテキストが折り返すようなデータフレームを印刷したいとします。コンソールに印刷するときにRの列内にテキストを折り返す方法は?

 v1    v2  v3 
1 TRUE Some text   TRUE 
2 TRUE Some more text FALSE 
3 TRUE This text wraps FALSE 
     after a certain 
     width 
4 FALSE Even more text FALSE 
5 TRUE More text   TRUE 

ここMWEです:

enter image description here

答えて

2

を見てみましょう:私がでてるところ

data.frame(v1 = c(TRUE, TRUE, TRUE, FALSE, TRUE), v2 = c("Some text", "Some more text", "This text wraps after a certain width", "Even more text", "More text"), y = c(TRUE, FALSE, FALSE, FALSE, TRUE)) 
options(width=10) 

はここだ理想的には、私は次のような何かをしたいですライブラリpanderpandoc.tableの機能それはあなたが何をしているかのようです。http://rapporter.github.io/pander/pandoc_table.html

library(pander) 
m<-data.frame(v1 = c(TRUE, TRUE, TRUE, FALSE, TRUE), v2 = c("Some text", "Some more text", "This text wraps after a certain width", "Even more text", "More text"), y = c(TRUE, FALSE, FALSE, FALSE, TRUE)) 
pandoc.table(m, split.cells = c(5, 20, 5)) 

#>--------------------------- 
#> v1   v2   y 
#>----- --------------- ----- 
#>TRUE  Some text TRUE 
#> 
#>TRUE Some more text FALSE 
#> 
#>TRUE This text wraps FALSE 
#>  after a certain  
#>   width   
#> 
#>FALSE Even more text FALSE 
#> 
#>TRUE  More text TRUE 
#>--------------------------- 
関連する問題