> On Oct 19, 2016, at 8:44 AM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> wrote: > > These don't look like "suffixes" to me, but whatever. > > s <- "abc" > substr( rep( s, length(s) ), 1, seq.int( length(s) ) )
I suspect that `nchar` was meant instead of `length` but it still failed. How about: lets <- paste0(letters,collapse=TRUE) unname( mapply( substr, lets, 1, 1:26) ) # mapply will recycle -- David. > > -- > Sent from my phone. Please excuse my brevity. > > On October 19, 2016 8:01:10 AM PDT, Witold E Wolski <wewol...@gmail.com> > wrote: >> Is there a build in function, which creates n suffixes of length 1:n >> from string of length n? >> e.g given abcd >> >> produces >> "a" >> "ab" >> "abc" >> >> >> FAST. >> >> equally nice to have would be: >> >> e.g. >> given c("a", "b", "c") >> produces >> "a" >> "a","b" >> "a","b","c" >> >> Thank you >> Witold > > ______________________________________________ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. David Winsemius Alameda, CA, USA ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.