Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go

Random Strings

20180604 It is sometimes very useful to be able to test out some code using some test data. A simple way to generate test strings us with stringi::stri_rand_lipsum().
stri_rand_lipsum(20)
##  [1] "Lorem ipsum dolor sit amet, sed, class metus, pretium risus ut con...
##  [2] "Donec id viverra nisl leo nunc, turpis nec eleifend ligula non. Ve...
##  [3] "Platea rutrum nam elit, accumsan curabitur malesuada tincidunt. In...
##  [4] "Curae inceptos velit egestas a iaculis vivamus dui ac ridiculus, v...
##  [5] "Habitant eleifend ut consequat sed eu pulvinar interdum dolor. Met...
##  [6] "Mi mauris magna mattis, lorem gravida, fames sed molestie. Aptent ...
##  [7] "Consequat ipsum eros luctus molestie. Blandit habitant massa, non ...
##  [8] "Lobortis magna elementum volutpat magna scelerisque, est ut eu qua...
##  [9] "Conubia sodales donec in egestas leo, ac nibh vehicula et pharetra...
## [10] "A nulla at, lacus nulla ligula ad, diam et erat, sed eget hendreri...
## [11] "A senectus, ridiculus lorem at felis. Ipsum sit sodales commodo qu...
## [12] "Vulputate sed, egestas parturient, platea dolor amet donec molesti...
## [13] "Metus lorem, pellentesque, lectus id elit scelerisque, pharetra na...
## [14] "Elementum euismod nibh in in pellentesque, tellus euismod purus el...
## [15] "Metus vel egestas ridiculus vestibulum turpis vehicula non dolor n...
## [16] "Dapibus, rhoncus turpis tempus leo rutrum. Sagittis ornare sed est...
## [17] "Sit ipsum vestibulum blandit sed a morbi, velit. Libero accumsan u...
## [18] "Orci ante dolor nullam fames adipiscing ad praesent in. Rhoncus ar...
## [19] "Efficitur habitasse magna faucibus augue ac non sollicitudin cras,...
## [20] "Non facilisis auctor justo risus convallis maecenas at eu orci. Et...
stri_rand_lipsum(2)
## [1] "Lorem ipsum dolor sit amet, class sapien auctor sit. Commodo dis su...
## [2] "Turpis quis elit dolor ornare velit maecenas netus velit ultrices. ...
sapply(stri_rand_lipsum(10), nchar, USE.NAMES=FALSE)
##  [1]  508  519  640  430  742  562  458 1048  680  426
sapply(stri_rand_lipsum(10), nchar, USE.NAMES=FALSE)
##  [1] 645 694 863 793 859 896 807 511 454 642

The strings generated are of different lengths and each call generates different strings.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.