Re: [R] Word-Wrapper Library/Package?

2021-09-29 Thread Leonard Mada via R-help
Many thanks for the hint. The function is actually a wrapper for: stringi:::stri_wrap I will need to have a closer look to this one (documentation and maybe also peek into the code): ret <- .Call(C_stri_wrap, str, width, cost_exponent, indent,     exdent, prefix, initial,

Re: [R] Word-Wrapper Library/Package?

2021-09-28 Thread Andrew Simmons
'strwrap' should wrap at the target column, so I think it's behaving correctly. You could do + 1 if you're expecting it to wrap immediately after the target column. As far as splitting while trying to minimize a penalty, I don't think strwrap can do that, and I don't know of any packages that do

Re: [R] Word-Wrapper Library/Package?

2021-09-28 Thread Leonard Mada via R-help
Thank you Andrew. I will explore this function more, although I am struggling to get it to work properly: strwrap("Abc. B. Defg", 7) # [1] "Abc." "B."   "Defg" # both "Abc. B." and "B. Defg" are 7 characters long. strwrap(paste0(rep("ab", 7), collapse=""), 7) # [1] "ababababababab" Can I

Re: [R] Word-Wrapper Library/Package?

2021-09-28 Thread Andrew Simmons
I think what you're looking for is 'strwrap', it's in package base. On Tue, Sep 28, 2021, 22:26 Leonard Mada via R-help wrote: > Dear R-Users, > > > Does anyone know any package or library that implements functions for > word wrapping? > > > I did implement a very rudimentary one (Github link

[R] Word-Wrapper Library/Package?

2021-09-28 Thread Leonard Mada via R-help
Dear R-Users, Does anyone know any package or library that implements functions for word wrapping? I did implement a very rudimentary one (Github link below), but would like to avoid to reinvent the wheel. Considering that word-wrapping is a very common task, it should be available even in