gridextra - R: Wrap text within grid.table when string exceeds set length -


i using grid.table within gridextra package display list of survey comments in table format. when comments(string variable) exceeds given length want automatically insert line break "\n".

library(gridextra) df<-data.frame(comments = c("here short string",  "here long string needs broken in half doesn't run off page", "here short string"))  grid.newpage() print(grid.table(df$comments)) 

i open using different table package if feature available elsewhere.

you can use strwrap,

 d = sapply(lapply(df$comments, strwrap, width=50), paste, collapse="\n")  grid.table(d) 

Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

android - Associate same looper with different threads -

visual studio 2010 - Connect to informix database windows form application -