Hi is there a way to limit the string text size for all columns in a data.frame, without having to loop through each column and using something like str_trunc one column at a time? For example the dataframe below, can I limit all text size to just 5 characters without having to do it one column at a time. If this had like 50 columns truncating one column at a time would be difficult.
g1 = data.frame (
gene = c( "aaaaaaa","aaaaaaa","aaaaaaaaaaaa","a","bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"),
value = c("1fdfdfdsfdsfdsfds","2fdfdfdfdsfds00","fdfdfds3","5ffffffffffff","0")
)
I tried something like this but failed. lapply(g1, str_trunc, 5)
Would be great if, with one go, I can limit any string in the dataframe to just 5 characters. so for example the first cell , row 1, column 1 would be just aaaaa
thanks.