Learn R Programming

charlatan (version 0.2.2)

LoremProvider: LoremProvider

Description

LoremProvider

Usage

lorem_provider_locales

Arguments

locale

(character) the locale to use. Run lorem_provider_locales() for locales supported (default: en_US)

sentence_punctuation

(character) End of sentence punctuation

word_connector

(character) Default connector between words

Format

An object of class character of length 9.

Details

Methods

  • word(ext_words = NULL) - Generate a random word

    • ext_words: a character vector of words you would like to have instead of 'Lorem ipsum'

    • returns: a random word

  • words(nb = 3, ext_words = NULL) - Generate a character vector of random words

    • nb: how many words to return

    • ext_words: a character vector of words you would like to have instead of 'Lorem ipsum'

    • returns: many words

  • sentence(nb_words, variable_nb_words, ext_words) - Generate a random sentence

    • nb_words around how many words the sentence should contain

    • variable_nb_words set to false if you want exactly nb words returned, otherwise the result may include a number of words of nb +/-40

    • ext_words a character vector of words you would like to have instead of 'Lorem ipsum'.

    • returns: a single sentence

  • sentences(nb, ext_words) - Generate a character vector of random sentences

    • nb: how many sentences to return

    • ext_words: a character vector of words you would like to have instead of 'Lorem ipsum'.

    • returns: many sentences

  • paragraph(nb_sentences, variable_nb_sentenc - ext_words)` - Generate a single paragraph

    • nb_sentences: around how many sentences the paragraph should contain

    • variable_nb_sentences: set to false if you want exactly nb sentences returned, otherwise the result may include a number of sentences of nb +/-40

    • ext_words: a character vector of words you would like to have instead of 'Lorem ipsum'

    • returns: a single paragraph

  • paragraphs(nb, ext_words) - Generate many paragraphs

    • nb: how many paragraphs to return

    • ext_words: a character vector of words you would like to have instead of 'Lorem ipsum'.

    • returns: many paragraphs

  • text(max_nb_chars, ext_words) - Generate a random text string. Depending on the max_nb_chars, returns a string made of words, sentences, or paragraphs.

    • max_nb_chars: Maximum number of characters the text should contain (minimum 5)

    • ext_words: a character vector of words you would like to have instead of 'Lorem ipsum'.

    • returns: character string of words

Examples

Run this code
# NOT RUN {
(x <- LoremProvider$new())
x$locale
x$word()
x$words(3)
x$words(6)
x$sentence()
x$sentences(3)
x$sentences(6)
x$paragraph()
x$paragraphs(3)
x$paragraphs(6)
cat(x$paragraphs(6), sep = "\n")
x$text(10)
x$text(25)
x$text(50)
x$text(300)
x$text(2000)

# set a different sentence_punctuation or word_connector
(x <- LoremProvider$new(sentence_punctuation = ";"))
x$paragraph(4)
(x <- LoremProvider$new(word_connector = " --- "))
x$paragraph(4)

# different locales
LoremProvider$new(locale = "ar_AA")$word()
LoremProvider$new(locale = "el_GR")$word()
LoremProvider$new(locale = "he_IL")$word()
LoremProvider$new(locale = "ja_JP")$word()
LoremProvider$new(locale = "zh_TW")$word()
# }

Run the code above in your browser using DataLab