> On Oct 19, 2016, at 9:41 AM, Jeff Newmiller <jdnew...@dcn.davis.ca.us> 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

> -- 
> Sent from my phone. Please excuse my brevity.
> 
> On October 19, 2016 9:36:25 AM PDT, David Winsemius <dwinsem...@comcast.net> 
> wrote:
>> 
>>> 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 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.

Reply via email to