Clinton Adams
Clinton Adams

Reputation: 121

Error: Package "ggplot2" could not be found, when loading the caret package

When I install caret with.

install.packages("caret", dependencies=c("Depends", "Suggests"))
library(caret)
## Loading required package: lattice
## Loading required package: ggplot2

Error in LoadNamespace(i, c(lib.loc, .libPaths()), versionCheck=vI[[i]]): there is no package called 'digest'
Error: package 'ggplot2' could not be loaded.

So I resolve the issue with the package digest by installing caret using this code and what do I get again:

install.packages("caret",  dep="TRUE")
library(caret)
## Loading required package: lattice
## Loading required package: ggplot2

Error in LoadNamespace(i, c(lib.loc, .libPaths()), versionCheck=vI[[i]]): there is no package called 'gtable'
Error: package 'ggplot2' could not be loaded.

How do I install caret successfully without this kind of errors, especially the ggplot2 error!

my R Version is R 3.2.2

Upvotes: 8

Views: 23801

Answers (5)

Andrickson Martinez
Andrickson Martinez

Reputation: 1

Unistall R and Rstudio. Make sure to delete all folders realated including the ones ion C:\Users<>\AppData\Local

Then re-install Rtools R Rstudio

Open Rstudio and execute << Make sure this is your path)

new_lib_path <- "C:/Program Files/R/R-4.2.3/library" if (!dir.exists(new_lib_path)) dir.create(new_lib_path) .libPaths(new_lib_path)

Upvotes: 0

Motasem HA
Motasem HA

Reputation: 1

install packages required and their library under R3.2.3 as caret built in this version and it is worked for me.

Upvotes: 0

Van
Van

Reputation: 1

Try this line to install ggplot2:

install.packages('ggplot2', repos='http://cran.us.r-project.org')

Upvotes: 0

Clinton Adams
Clinton Adams

Reputation: 121

Thanks guys for the help. I did try install.packages("caret", dep="TRUE") which installed the package digest, then tried install.packages("ggplot") which installed ggplot with the dependency gtable but still had some missing packages. Did finally manage to load caret without any problems after installing the missing packages as prompted.

Upvotes: 3

topepo
topepo

Reputation: 14316

You are missing some packages that ggplot2 imports (e.g. digest and gtable)

You should probably use

install.packages("caret", dependencies = c("Depends", "Imports", "Suggests"))

This should be the same as dep = TRUE but, when I use the character string above, I get all the requirements.

Upvotes: 0

Related Questions