Let\'s have a dataframe with long strings in one column:
df<-data.frame(short=rnorm(10,0,1),long=replicate(10,paste(rep(sample(letters),runif(1,5,8)),collaps
Uses dplyr and prints out a modified version of the original data frame (without changing it). Only shortens values which exceed specified length:
library(dplyr) print.data.frame(df %>% mutate(long = ifelse( nchar(long > 11), paste0(substr(long, 1, 8), "..."), long )))