I'm trying to pick a random letter, 2 letters, 3 letters, ..., words with the most letters from each sentence. Then combine these words with a space as a phrase.
new_data <- sample_n(data.frame(stringr::sentences), 30)
new_data
split_data <- data.frame(X = str_remove_all(new_data$stringr..sentences, "[.,]"))
split_data
split_data <- strsplit(split_data$X," ")
split_data
for(i in split_data){
generated <- split_data %>%
lapply(nchar)
}
It should have an output like this:
The sentences I randomly selected are
"The long journey home took a year."
"The young prince became heir to the throne."
…
The generated phrases are
“a The year journey”
“to the heir young became”
…