Problem with the ggplot2 package and the ggpairs command?

Good afternoon,
when running the following script

#https://uoftcoders.github.io/rcourse/lec01-introduction.html
library(ggplot2)
require(GGally)
iris <- read.csv("~/R software/RR SCRIPT/Introduction to course R/iris.csv")
iris
mean(iris$Petal.Length )
summary(iris)

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width))+geom_point()

ggplot(iris, aes(x = Sepal.Length, y = Sepal.Width, color = Species))+geom_point()

ggplot(iris, aes(x = Petal.Length, fill = Species)) +geom_histogram()

ggplot(iris, aes(x = Petal.Length, fill = Species)) +
  geom_histogram() +
  facet_wrap(~ Species, dir = 'v')

ggpairs(iris, aes(color = Species))

I have the following alert:

ggpairs(iris, aes(color = Species))
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called ‘stringi’

when installing the "stringi" package
I receive the following statements:

install.packages('stringi')

  There is a binary version available but the source version is later:
        binary source needs_compilation
stringi  1.1.7  1.2.3              TRUE

installing the source package ‘stringi’

trying URL 'https://cran.rstudio.com/src/contrib/stringi_1.2.3.tar.gz'
Content type 'application/x-gzip' length 7270993 bytes (6.9 MB)
downloaded 6.9 MB

* installing *source* package 'stringi' ...
** package 'stringi' successfully unpacked and MD5 sums checked
Warning in system("sh ./configure.win") : 'sh' not found
ERROR: configuration failed for package 'stringi'
* removing 'C:/Program Files/R/R-3.5.0/library/stringi'
In R CMD INSTALL
Warning in install.packages :
  installation of package ‘stringi’ had non-zero exit status

The downloaded source packages are in
	‘C:\Users\hermesr\AppData\Local\Temp\Rtmpe0YD1m\downloaded_packages’

and running the script again repeats the first alert:

ggpairs(iris, aes(color = Species))
Error in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]) : 
  there is no package called ‘stringi’

Any recommendation to run the script successfully?
Gracias
Hermes

now at all times I have the same alert:

# We could also do `library(dplyr)`, but we need the rest of the
> # tidyverse packages later, so we might as well import the entire collection.
> l .... [TRUNCATED] 
Error: package or namespace load failed for ‘tidyverse’ in loadNamespace(i, c(lib.loc, .libPaths()), versionCheck = vI[[i]]):
 there is no package called ‘stringi’
> 

When I installed the package, Rstudio sent the following msg:
Rstudio%20alerta

Do you have RTools? If you're on Windows, you might need that to compile from source.

4 Likes

To hopefully clarify a bit (since the installation messages are definitely not the most user-friendly), this line:

means that stringi failed to install (because, in this case, you were installing from source, stringi needs compilation, and it failed to compile). That's why you keep getting error messages about stringi being missing.

As Mara said, if you haven't installed RTools before, you will need to do that if you want to install packages from source that need compilation (these are ones with C++ or Fortran code). But if you want to try to quickly get moving again, you can see what happens if you install the older pre-compiled binary version of stringi (run install.packages("stringi", type = "binary"). It's possible that there will be incompatibilities with the packages depending on stringi, but this can sometimes be a useful stopgap.

You might also want to check out the installr project, which tries to make package installation on Windows easier:

2 Likes

I receive the following alert:

install.packages("Rtools", dependencies = TRUE, repos = "http://cran.us.r-project.org")
Warning in install.packages :
  package ‘Rtools’ is not available (for R version 3.5.0)

How to proceed?

Rtools isn't an R package. See details here:
https://cran.r-project.org/bin/windows/Rtools/

This is how you install Rtools on Windows

2 Likes