Re: [R] create n suffixes of length 1:n from string of length n

2016-10-19 Thread David Winsemius
> On Oct 19, 2016, at 9:41 AM, Jeff Newmiller wrote: > > When I replace length with nchar, it works fine for me without mapply. > > substr( rep( s, nchar(s) ), 1, seq.int( nchar(s) ) ) I failed to make the second `nchar` -> `length` substitution. It now works for me as well. -- David > --

Re: [R] create n suffixes of length 1:n from string of length n

2016-10-19 Thread Jeff Newmiller
When I replace length with nchar, it works fine for me without mapply. substr( rep( s, nchar(s) ), 1, seq.int( nchar(s) ) ) -- Sent from my phone. Please excuse my brevity. On October 19, 2016 9:36:25 AM PDT, David Winsemius wrote: > >> On Oct 19, 2016, at 8:44 AM, Jeff Newmiller > wrote: >>

Re: [R] create n suffixes of length 1:n from string of length n

2016-10-19 Thread David Winsemius
> On Oct 19, 2016, at 8:44 AM, Jeff Newmiller 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,

Re: [R] create n suffixes of length 1:n from string of length n

2016-10-19 Thread Jeff Newmiller
These don't look like "suffixes" to me, but whatever. s <- "abc" substr( rep( s, length(s) ), 1, seq.int( length(s) ) ) -- Sent from my phone. Please excuse my brevity. On October 19, 2016 8:01:10 AM PDT, Witold E Wolski wrote: >Is there a build in function, which creates n suffixes of length

Re: [R] create n suffixes of length 1:n from string of length n

2016-10-19 Thread Bob Rudis
purrr::map(paste0(letters, collapse=""), ~purrr::map2_chr(., 1:nchar(.), ~substr(.x, 1, .y)))[[1]] seems to crank really fast at least on my system what did you try that was slow? On Wed, Oct 19, 2016 at 11:01 AM, Witold E Wolski wrote: > Is there a build in function, which creates n suffixes o