我在 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))
如果此功能在其他地方可用,我愿意使用不同的表包。