Text Mining with R: Crashing

I started going through the Text Mining with R textbook, and while running the code from the textbook, R is crashes. I looked in /var/logs/rstudio/server/* for any hints, and could find nothing. Also, in the console I saw nothing related to why the system was crashing. When R does crash after running this code, I see an error pop up which is generic and stating that R has crashed abnormally and I may have experienced data loss.

I've tried restarting R several times, updating packages, and nothing has worked.

How do I go about debugging this issue, or is there a solution to this type of issue?

Version: RStudio Server2022.07.1 Build 554
OS: Arch Linux
Kernel: 5.19.11-arch1-1
CPU: Intel i5-6500 (4) @ 3.600GHz
RAM: 16Gb
GPU: NVIDIA GeForce GTX 1050 Ti

This is the code I am running:

library(dplyr)
library(tidyverse)
text <- c("Because I could not stop for Death -",
 "He kindly stopped for me -",
 "The Carriage held but just Ourselves -",
 "and Immortality")

text_df <- data_frame(line=1:4, text=text)

text_df

library(tidytext)
?unnest_tokens
text_df %>%
  unnest_tokens(word, text)
library(janeaustenr)
original_books <- austen_books() %>%
  group_by(book) %>%
  mutate(linenumber = row_number(),
         chapter = cumsum(str_detect(text, regex("^chapter [\\divxlc]", ignore_case = TRUE)))) %>%
  ungroup()

original_books
tidy_books <- original_books %>%
  unnest_tokens(word, text)
tidy_books
data(stop_words)
tidy_books <- tidy_books %>%
  anti_join(stop_words)

tidy_books %>%
  count(word, sort = TRUE)

** The code block below is what causes R to crash, and dump the data environment.**

tidy_books %>%
  count(word, sort = TRUE) %>%
  filter(n > 600) %>%
  mutate(word = reorder(word, n)) %>%
  ggplot(aes(word, n)) +
  geom_col() +
  xlab(NULL) +
  coord_flip()

Update:

After a server restart R stops crashing, I think the kernel update required a full shutdown before powering on again. However, now I am having text render issues with the ggplot package.

try changing this setting: Options, General, Graphics, Graphics Device, Backend to Cairo for example

1 Like

Thanks, the solution for me was using ACG, Cairo made no difference. Thank you for directing me.

This topic was automatically closed 7 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.