This is a wrapper around stringi::stri_wrap()
which implements
the Knuth-Plass paragraph wrapping algorithm.
str_wrap(string, width = 80, indent = 0, exdent = 0)
string | character vector of strings to reformat. |
---|---|
width | positive integer giving target line width in characters. A width less than or equal to 1 will put each word on its own line. |
indent | non-negative integer giving indentation of first line in each paragraph |
exdent | non-negative integer giving indentation of following lines in each paragraph |
A character vector of re-wrapped strings.
thanks_path <- file.path(R.home("doc"), "THANKS") thanks <- str_c(readLines(thanks_path), collapse = "\n") thanks <- word(thanks, 1, 3, fixed("\n\n")) cat(str_wrap(thanks), "\n")#> R would not be what it is today without the invaluable help of these people #> outside of the R core team, who contributed by donating code, bug fixes and #> documentation: Valerio Aimale, Suharto Anggono, Thomas Baier, Henrik Bengtsson, #> Roger Bivand, Ben Bolker, David Brahm, G"oran Brostr"om, Patrick Burns, Vince #> Carey, Saikat DebRoy, Matt Dowle, Brian D'Urso, Lyndon Drake, Dirk Eddelbuettel, #> Claus Ekstrom, Sebastian Fischmeister, John Fox, Paul Gilbert, Yu Gong, Gabor #> Grothendieck, Frank E Harrell Jr, Peter M. Haverty, Torsten Hothorn, Robert #> King, Kjetil Kjernsmo, Roger Koenker, Philippe Lambert, Jan de Leeuw, Jim #> Lindsey, Patrick Lindsey, Catherine Loader, Gordon Maclean, John Maindonald, #> David Meyer, Ei-ji Nakama, Jens Oehlschaegel, Steve Oncley, Richard O'Keefe, #> Hubert Palme, Roger D. Peng, Jose' C. Pinheiro, Tony Plate, Anthony Rossini, #> Jonathan Rougier, Petr Savicky, Guenther Sawitzki, Marc Schwartz, Arun #> Srinivasan, Detlef Steuer, Bill Simpson, Gordon Smyth, Adrian Trapletti, Terry #> Therneau, Rolf Turner, Bill Venables, Gregory R. Warnes, Andreas Weingessel, #> Morten Welinder, James Wettenhall, Simon Wood, and Achim Zeileis. Others have #> written code that has been adopted by R and is acknowledged in the code files, #> including#> R would not be what it is today #> without the invaluable help of these #> people outside of the R core team, who #> contributed by donating code, bug fixes #> and documentation: Valerio Aimale, #> Suharto Anggono, Thomas Baier, Henrik #> Bengtsson, Roger Bivand, Ben Bolker, #> David Brahm, G"oran Brostr"om, Patrick #> Burns, Vince Carey, Saikat DebRoy, Matt #> Dowle, Brian D'Urso, Lyndon Drake, Dirk #> Eddelbuettel, Claus Ekstrom, Sebastian #> Fischmeister, John Fox, Paul Gilbert, #> Yu Gong, Gabor Grothendieck, Frank E #> Harrell Jr, Peter M. Haverty, Torsten #> Hothorn, Robert King, Kjetil Kjernsmo, #> Roger Koenker, Philippe Lambert, Jan #> de Leeuw, Jim Lindsey, Patrick Lindsey, #> Catherine Loader, Gordon Maclean, John #> Maindonald, David Meyer, Ei-ji Nakama, #> Jens Oehlschaegel, Steve Oncley, Richard #> O'Keefe, Hubert Palme, Roger D. Peng, #> Jose' C. Pinheiro, Tony Plate, Anthony #> Rossini, Jonathan Rougier, Petr Savicky, #> Guenther Sawitzki, Marc Schwartz, Arun #> Srinivasan, Detlef Steuer, Bill Simpson, #> Gordon Smyth, Adrian Trapletti, Terry #> Therneau, Rolf Turner, Bill Venables, #> Gregory R. Warnes, Andreas Weingessel, #> Morten Welinder, James Wettenhall, Simon #> Wood, and Achim Zeileis. Others have #> written code that has been adopted by R #> and is acknowledged in the code files, #> including#> R would not be what it is today without the invaluable help #> of these people outside of the R core team, who contributed #> by donating code, bug fixes and documentation: Valerio #> Aimale, Suharto Anggono, Thomas Baier, Henrik Bengtsson, #> Roger Bivand, Ben Bolker, David Brahm, G"oran Brostr"om, #> Patrick Burns, Vince Carey, Saikat DebRoy, Matt Dowle, #> Brian D'Urso, Lyndon Drake, Dirk Eddelbuettel, Claus #> Ekstrom, Sebastian Fischmeister, John Fox, Paul Gilbert, #> Yu Gong, Gabor Grothendieck, Frank E Harrell Jr, Peter M. #> Haverty, Torsten Hothorn, Robert King, Kjetil Kjernsmo, #> Roger Koenker, Philippe Lambert, Jan de Leeuw, Jim Lindsey, #> Patrick Lindsey, Catherine Loader, Gordon Maclean, John #> Maindonald, David Meyer, Ei-ji Nakama, Jens Oehlschaegel, #> Steve Oncley, Richard O'Keefe, Hubert Palme, Roger D. Peng, #> Jose' C. Pinheiro, Tony Plate, Anthony Rossini, Jonathan #> Rougier, Petr Savicky, Guenther Sawitzki, Marc Schwartz, #> Arun Srinivasan, Detlef Steuer, Bill Simpson, Gordon #> Smyth, Adrian Trapletti, Terry Therneau, Rolf Turner, Bill #> Venables, Gregory R. Warnes, Andreas Weingessel, Morten #> Welinder, James Wettenhall, Simon Wood, and Achim Zeileis. #> Others have written code that has been adopted by R and is #> acknowledged in the code files, including#> R would not be what it is today without the invaluable help #> of these people outside of the R core team, who contributed #> by donating code, bug fixes and documentation: Valerio #> Aimale, Suharto Anggono, Thomas Baier, Henrik Bengtsson, #> Roger Bivand, Ben Bolker, David Brahm, G"oran Brostr"om, #> Patrick Burns, Vince Carey, Saikat DebRoy, Matt Dowle, #> Brian D'Urso, Lyndon Drake, Dirk Eddelbuettel, Claus #> Ekstrom, Sebastian Fischmeister, John Fox, Paul Gilbert, #> Yu Gong, Gabor Grothendieck, Frank E Harrell Jr, Peter M. #> Haverty, Torsten Hothorn, Robert King, Kjetil Kjernsmo, #> Roger Koenker, Philippe Lambert, Jan de Leeuw, Jim Lindsey, #> Patrick Lindsey, Catherine Loader, Gordon Maclean, John #> Maindonald, David Meyer, Ei-ji Nakama, Jens Oehlschaegel, #> Steve Oncley, Richard O'Keefe, Hubert Palme, Roger D. Peng, #> Jose' C. Pinheiro, Tony Plate, Anthony Rossini, Jonathan #> Rougier, Petr Savicky, Guenther Sawitzki, Marc Schwartz, #> Arun Srinivasan, Detlef Steuer, Bill Simpson, Gordon #> Smyth, Adrian Trapletti, Terry Therneau, Rolf Turner, Bill #> Venables, Gregory R. Warnes, Andreas Weingessel, Morten #> Welinder, James Wettenhall, Simon Wood, and Achim Zeileis. #> Others have written code that has been adopted by R and is #> acknowledged in the code files, including#> R #> would #> not #> be #> what #> it #> is #> today #> without #> the #> invaluable #> help #> of #> these #> people #> outside #> of #> the #> R #> core #> team, #> who #> contributed #> by #> donating #> code, #> bug #> fixes #> and #> documentation: #> Valerio #> Aimale, #> Suharto #> Anggono, #> Thomas #> Baier, #> Henrik #> Bengtsson, #> Roger #> Bivand, #> Ben #> Bolker, #> David #> Brahm, #> G"oran #> Brostr"om, #> Patrick #> Burns, #> Vince #> Carey, #> Saikat #> DebRoy, #> Matt #> Dowle, #> Brian #> D'Urso, #> Lyndon #> Drake, #> Dirk #> Eddelbuettel, #> Claus #> Ekstrom, #> Sebastian #> Fischmeister, #> John #> Fox, #> Paul #> Gilbert, #> Yu #> Gong, #> Gabor #> Grothendieck, #> Frank #> E #> Harrell #> Jr, #> Peter #> M. #> Haverty, #> Torsten #> Hothorn, #> Robert #> King, #> Kjetil #> Kjernsmo, #> Roger #> Koenker, #> Philippe #> Lambert, #> Jan #> de #> Leeuw, #> Jim #> Lindsey, #> Patrick #> Lindsey, #> Catherine #> Loader, #> Gordon #> Maclean, #> John #> Maindonald, #> David #> Meyer, #> Ei- #> ji #> Nakama, #> Jens #> Oehlschaegel, #> Steve #> Oncley, #> Richard #> O'Keefe, #> Hubert #> Palme, #> Roger #> D. #> Peng, #> Jose' #> C. #> Pinheiro, #> Tony #> Plate, #> Anthony #> Rossini, #> Jonathan #> Rougier, #> Petr #> Savicky, #> Guenther #> Sawitzki, #> Marc #> Schwartz, #> Arun #> Srinivasan, #> Detlef #> Steuer, #> Bill #> Simpson, #> Gordon #> Smyth, #> Adrian #> Trapletti, #> Terry #> Therneau, #> Rolf #> Turner, #> Bill #> Venables, #> Gregory #> R. #> Warnes, #> Andreas #> Weingessel, #> Morten #> Welinder, #> James #> Wettenhall, #> Simon #> Wood, #> and #> Achim #> Zeileis. #> Others #> have #> written #> code #> that #> has #> been #> adopted #> by #> R #> and #> is #> acknowledged #> in #> the #> code #> files, #> including