formatC
to justify the strings if needed.StrTrunc(x, maxlen = 20)
nchar
, match
, grep
, regexpr
, substr
, sub
, gsub
,
StrTrim
, StrDist
set.seed(1789)
x <- sapply(seq(10), function(x) paste(sample(letters, sample(20,1)),collapse=""))
x
StrTrunc(x, maxlen=10)
# right justification
formatC(StrTrunc(x, maxlen=10), width = 10, flag="")
Run the code above in your browser using DataLab