6

gridExtra パッケージ内で grid.table を使用して、調査コメントのリストを表形式で表示しています。コメント(文字列変数)が一定の長さを超えると、自動的に改行「\n」を挿入したい。

library(gridExtra)
df<-data.frame(comments = c("Here is a short string", 
"Here is a long string that needs to be broken in half so that it doesn't run off the page",
"Here is another short string"))

grid.newpage()
print(grid.table(df$comments))

この機能が他の場所で利用できる場合は、別のテーブル パッケージを使用することにオープンです。

4

1 に答える 1

5

ストラップを使用できます。

 d = sapply(lapply(df$comments, strwrap, width=50), paste, collapse="\n")
 grid.table(d)
于 2014-09-10T14:50:33.090 に答える