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

5

8

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

Lucretialucretius answered 16/10, 2015 at 19:42 Comment(7)
what happens if you try install.packages("ggplot2")?Rigorism
install.packages("caret", dep="TRUE") should be install.packages("caret", dep=TRUE) (without quotes, so it's a boolean instead of a string)Talishatalisman
Maybe just try running update.packages(). Sounds like you've gotten your package versions out-of-sync somehow.Mcgriff
Also, what are the results of .libPaths()?Simeon
@Rigorism I did that and it worked out fine but there was still some missing packages so it still couldn't load. Had to install them individually till ggplot could load in RLucretialucretius
@CactusWoman Thanks for that, it did load most of the missing packages, not all though.Lucretialucretius
@Mcgriff doubt that was the case then, .libPaths() just displayed the location of the library on my PCLucretialucretius
L
3

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.

Lucretialucretius answered 18/10, 2015 at 14:22 Comment(0)
S
0

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.

Simeon answered 17/10, 2015 at 18:25 Comment(0)
P
0

Try this line to install ggplot2:

install.packages('ggplot2', repos='http://cran.us.r-project.org')
Prejudicial answered 1/10, 2016 at 1:7 Comment(0)
H
0

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

Huddle answered 11/8, 2017 at 12:1 Comment(2)
install.packages("randomForest") install.packages("lattice") install.packages("ggplot2") install.packages("caret") library(lattice) library(ggplot2) library(caret)Huddle
Just edit your answer to accommodate the actual packages instead of adding them as comments.Manhunt
O
0

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)

Outdoors answered 22/4, 2023 at 2:12 Comment(1)
The OP's issue can be solved without uninstalling R and RStudio, as outlined by the other answers to this question.Pentane

© 2022 - 2024 — McMap. All rights reserved.