How to shuffle texts?

Hello. I have a problem with this code.

library(ggplot2)
library(magrittr)
library(dplyr)
library(tidytext)
library(gutenbergr)
library(tm)
library(fields)
g_en <- gutenberg_works(languages = "en")
g_fr <- gutenberg_works(languages = "fr")
en <- gutenberg_download(c(103, 18857, 1268, 83, 2083, 29413, 16457, 3526), mirror = "something")
fr <- gutenberg_download(c(800, 4791, 14287, 799, 14163, 11927, 4717, 4548), mirror = "something")
books_en <- g_en[g_en$gutenberg_id %in% c(103, 18857, 1268, 83, 2083, 29413, 16457, 3526),c("gutenberg_id","title")]
books_fr <- g_fr[g_fr$gutenberg_id %in% c(800, 4791, 14287, 799, 14163, 11927, 4717, 4548),c("gutenberg_id","title")]
en %<>% left_join(books_en) %>% mutate(gutenberg_id = NULL)
fr %<>% left_join(books_fr) %>% mutate(gutenberg_id = NULL)
verne_words_en <- en %>% unnest_tokens(word, text) %>% count(title, word, sort = TRUE)
verne_words_fr <- fr %>% unnest_tokens(word, text) %>% count(title, word, sort = TRUE)
verne_heaps_en <- en %>% unnest_tokens(word, text) %>% group_by(title) %>% mutate(M = row_number(), V = cumsum(!duplicated(word)))
verne_heaps_fr <- fr %>% unnest_tokens(word, text) %>% group_by(title) %>% mutate(M = row_number(), V = cumsum(!duplicated(word)))
verne_sum_en <- verne_heaps_en %>% summarise(a = lm(log10(V) ~ log10(M))$coefficients[1], b = lm(log10(V) ~ log10(M))$coefficients[2])
verne_sum_fr <- verne_heaps_fr %>% summarise(a = lm(log10(V) ~ log10(M))$coefficients[1], b = lm(log10(V) ~ log10(M))$coefficients[2])
print("Dla kazdego tekstu parametr beta jest rowny wspolczynnikowi a.")
verne_sum_en
verne_sum_fr
shuffle(en)
shuffle(fr)
verne_words_en <- en %>% unnest_tokens(word, text) %>% count(title, word, sort = TRUE)
verne_words_fr <- fr %>% unnest_tokens(word, text) %>% count(title, word, sort = TRUE)
verne_heaps_en <- en %>% unnest_tokens(word, text) %>% group_by(title) %>% mutate(M = row_number(), V = cumsum(!duplicated(word)))
verne_heaps_fr <- fr %>% unnest_tokens(word, text) %>% group_by(title) %>% mutate(M = row_number(), V = cumsum(!duplicated(word)))
verne_sum_en <- verne_heaps_en %>% summarise(a = lm(log10(V) ~ log10(M))$coefficients[1], b = lm(log10(V) ~ log10(M))$coefficients[2])
verne_sum_fr <- verne_heaps_fr %>% summarise(a = lm(log10(V) ~ log10(M))$coefficients[1], b = lm(log10(V) ~ log10(M))$coefficients[2])
print("Dla kazdego tekstu parametr beta jest rowny wspolczynnikowi a.")
verne_sum_en
verne_sum_fr

In the 25 and 26 line I try to shuffle every book, butI' ve got an errors "Błąd w poleceniu 'shuffle(en)':nie udało się znaleźć funkcji 'shuffle'" and "Błąd w poleceniu 'shuffle(fr)':nie udało się znaleźć funkcji 'shuffle'" and I don't know how to fix this.

shuffle is not a base R function, if it is to come from a library then you need to declare the library.
According to this resource there are quite a few functions called shuffle

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.