murders %>% + ggplot(aes (population, total" /> murders %>% + ggplot(aes (population, total" /> murders %>% + ggplot(aes (population, total"/>

Having trouble loading tidyverse library

254 views Asked by At
install.packages("dslabs")
install.packages("tidyverse")
library(dslabs)
library(tidyverse)
data(murders)> murders %>%
+   ggplot(aes (population, total, label=abb, color=region)) +
+   geom_label()
Error in murders %>% ggplot(aes(population, total, label = abb, color = region)) : 
  could not find function "%>%"
> murders |>
+   ggplot(aes (population, total, label=abb, color=region)) +
+   geom_label()
Error in ggplot(murders, aes(population, total, label = abb, color = region)) : 
  could not find function "ggplot"

Numerous errors with R-4.2.2 in R Studio 2022.12.15 with RTools 4.2. I just tried to reinstall and I got the following error:

Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 there is no package called ‘stringi’

Tried two different computers. Tried all the suggestions I could possibly find online (installing and loading magrittr, dplyr, or replacing pipe operator). Finally replacing the pipe operator worked, I think, but then other terms aren't recognized, as if tidyverse is not installed.

It has to be something basic I'm doing wrong, repeatedly. I restarted everything after installing stringi, and when I loaded tidyverse now I get this message, which could explain why the pipe operator is not being recognized:

> library(tidyverse)
── Attaching packages ─────────────────────────────── tidyverse 1.3.2 ──
    ✔ ggplot2 3.4.0      ✔ purrr   1.0.1 
    ✔ tibble  3.1.8      ✔ dplyr   1.0.10
    ✔ tidyr   1.2.1      ✔ stringr 1.5.0 
    ✔ readr   2.1.3      ✔ forcats 0.5.2 
    ── Conflicts ────────────────────────────────── 
    tidyverse_conflicts() ──
    ✖ dplyr::filter() masks stats::filter()
    ✖ dplyr::lag()    masks stats::lag()
2

There are 2 answers

2
Julie McMinn On

Based on the suggestion in the comments, I installed the stringi package, which totally worked once I restarted my computer and reran my script.

2
Hadia On

Clicking Ctrl+Enter on Windows after every line of code to run script line-by-line. Remember to save the file first, because there is no mistake in the code.