Error in library(ggplot2) : There is no package called 'ggplot2' - r

I'm new to R and I'm just trying to get through some tutorials.
When I try installing ggplot2, I get this error.
Error in library(ggplot2) : There is no package called 'ggplot2'
I tried these in R and RStudio.
install.packages("ggplot2", dep=T)
install.packages('ggplot2', repos='http://cran.us.r-project.org')
remove.packages("ggplot2")
but I get the error
(Error in remove.packages : there is no package called 'ggplot2')
This is what I get from install.packages("ggplot2")
> install.packages("ggplot2")
Installing package into ‘.../R/win-library/3.4’
(as ‘lib’ is unspecified)
Warning in install.packages :
'lib = ".../R/win-library/3.4"' is not writable
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.4/ggplot2_2.2.1.zip'
Content type 'application/zip' length 2784566 bytes (2.7 MB)
downloaded 2.7 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘ggplot2’
The downloaded binary packages are in
C:...\AppData\Local\temp\RtmpqaGNpr\downloaded_packages
I removed all ggplot2 files manually then tried to install again. Here's my result.
> install.packages("ggplot2")
Installing package into ‘.../R/win-library/3.4’
(as ‘lib’ is unspecified)
--- Please select a CRAN mirror for use in this session ---
trying URL 'https://ftp.osuosl.org/pub/cran/bin/windows/contrib/3.4/ggplot2_2.2.1.zip'
Content type 'application/zip' length 2784566 bytes (2.7 MB)
downloaded 2.7 MB
package ‘ggplot2’ successfully unpacked and MD5 sums checked
Warning: unable to move temporary installation ‘...\R\win-library\3.4\file26b43a54980\ggplot2’ to ‘...\R\win-library\3.4\ggplot2’
The downloaded binary packages are in
C:...\AppData\Local\temp\Rtmpq0T9a6\downloaded_packages
> library(ggplot2)
Error in library(ggplot2) : there is no package called ‘ggplot2’
> library("ggplot2")
Error in library("ggplot2") : there is no package called ‘ggplot2’
These code was run using R 3.4.2

Steps
Go To Tools
Install Packages
In Packages Text Box Type ggplot2
Check the checkbox install dependencies

When having this issue I would suggest :
try turning it off and on again
update R to last version if possible
remove manually all the folders related to the relevant package and retry the installation
change your default library location : How do you change library location in R?

Try launching R client directly from command prompt, then issue the instruction:
install.packages("ggplot2", lib="C:/Users/YourUser/Documents/R/win-library/3.3")

You need to update your R version and do this but you'll need install all packages again:
Tool > Global Options > R version (CHANGE) > Select "Use your machine's default version of R..."

Related

Can't install caret package

I'm not sure what's happening here but the caret package is not installing properly. I realize similar problems have been posted before but I can't figure it out.
install.packages("caret")
library(caret)
Error: package or namespace load failed for ‘caret’ in get(Info[i, 1], envir = env):
cannot open file 'C:/Users/John Compton/Documents/R/win-library/3.6/MASS/R/MASS.rdb': No such file or directory
So I've been trying to figure this out. I have the fully updated R 3.6.1, I also ran a thing that I've since lost of like install.packages("caret", repos = "cran/....", c = ("Dependencies", "Suggestions")) which took about 30 minutes and installed like every suggested package, so I don't know what the error could be. How do I fix the error with this package?
Edit: To include the install.package call
> install.packages("caret")
Installing package into ‘C:/Users/John Compton/Documents/R/win-library/3.6’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.6/caret_6.0-84.zip'
Content type 'application/zip' length 6237886 bytes (5.9 MB)
downloaded 5.9 MB
package ‘caret’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\John Compton\AppData\Local\Temp\RtmpGuKafa\downloaded_packages
>

Install error on mxnet

I am trying to install mxnet for use with R Studio on my Windows 10 laptop.
I used these instuctions:
install.packages("drat", repos="https://cran.rstudio.com")
drat:::addRepo("dmlc")
install.packages("mxnet")
But when I try this:
require(mxnet)
I get the error message:
Loading required package: mxnet
Error : object ‘combine_edges’ is not exported by 'namespace:DiagrammeR'
Here is the complete console:
> install.packages("drat", repos = "https://cran.rstudio.com")
Installing package into ‘C:/Users/bill_/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.3/drat_0.1.2.zip'
Content type 'application/zip' length 73095 bytes (71 KB)
downloaded 71 KB
package ‘drat’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\bill_\AppData\Local\Temp\RtmpIDZk6c\downloaded_packages
> drat:::addRepo("dmlc")
> install.packages("mxnet")
Installing package into ‘C:/Users/bill_/Documents/R/win-library/3.3’
(as ‘lib’ is unspecified)
trying URL 'https://dmlc.github.io/drat/bin/windows/contrib/3.3/mxnet_0.7.zip'
Content type 'application/zip' length 5196542 bytes (5.0 MB)
downloaded 5.0 MB
package ‘mxnet’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\bill_\AppData\Local\Temp\RtmpIDZk6c\downloaded_packages
> require(mxnet)
Loading required package: mxnet
Error : object ‘combine_edges’ is not exported by 'namespace:DiagrammeR'
>
Can anyone help?
Thanks in advance.
SOLUTION FOUND PER AXEMAN'S SUGGESTION...
# version 0.9.0 of DiagrammeR won't work with mxnet at this time (20170104)
require(devtools)
install_version("DiagrammeR", version = "0.8.1", repos = "http://cran.us.r-project.org")
With latest repo, you should be able to complete installation. They have removed references to "combine_edges" which was removed from latest DiagrammeR.

Persistent problems installing the car package in R

I'm having problems installing the package car in R.
There are previous posts on the topic, including this one and this other one.
I have followed the suggestions I've come across so far without success. I am using R Version 3.2.2. and RStudio.
This is the message I get:
install.packages("car")
Installing package into ‘C:/Users/.../Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/car_2.1-3.zip'
Content type 'application/zip' length 1447213 bytes (1.4 MB)
downloaded 1.4 MB
package ‘car’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\...\AppData\Local\Temp\Rtmpc3xr5i\downloaded_packages
If I check I get,
?car
No documentation for ‘car’ in specified packages and libraries:
you could try ‘??car’
I tried installing it from R with Install packages from local zip drives, and looking for the zip in C:\Users\...\AppData\Local\Temp\Rtmpc3xr5i\downloaded_packages, but this is the result:
library(car)
Error in library.dynam(lib, package, package.lib) :
DLL ‘SparseM’ not found: maybe not installed for this architecture?
In addition: Warning message:
package ‘car’ was built under R version 3.2.5
Error: package or namespace load failed for ‘car’
I did try installing SparseM even before posting the OP without success:
> install.packages("SparseM")
Installing package into ‘C:/Users/.../Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/SparseM_1.7.zip'
Content type 'application/zip' length 795531 bytes (776 KB)
downloaded 776 KB
package ‘SparseM’ successfully unpacked and MD5 sums checked
The downloaded binary packages are in
C:\Users\...\AppData\Local\Temp\Rtmpc3xr5i\downloaded_packages
> ?SparseM
No documentation for ‘SparseM’ in specified packages and libraries:
you could try ‘??SparseM’
Follow up:
After a comment regarding R version 3.2.3 I thought it would be an easy fix to just download this version, install, and erase 3.2.2. The problem then is that RStudio did not seem to work. I un-installed and re-installed R-studio, and now I get this when opening R studio:
Without knowing what version of the car package you're using, it's hard to know exactly what the source of the problem is. It seems likely, however, that you haven't installed the proper version of the pbkrtest, on which the Rcmdr package depends.
Is there a compelling reason not to upgrade everything to their current versions, including R, all packages, and RStudio?
Best,
John

Devtools/library download error

I am trying to install Devtools into Rstudio. I was using Rgui, but decided to use Rstudio becuase it seems to be easier. I able to get DevTools on Rgui, but not RStudio.
Basicly. the library on Rstudio does not have DEVtools installed and I am having problems. Any ideas?
I tried the install.packages("devtools") states it is install in y computer, but does not show in the library. I tried GitHub. did not wok either.
install.packages("devtools")
Installing package into ‘C:/Users/Steven/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
trying
URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/devtools_1.10.0.zip'
Content type 'application/zip' length 391482 bytes (382 KB)
downloaded 382 KB
package ‘devtools’ successfully unpacked and MD5 sums checked
Warning in install.packages :
cannot remove prior installation of package ‘devtools’
The downloaded binary packages are in
C:\Users\Steven\AppData\Local\Temp\RtmpkxtbPl\downloaded_packages
However, I do Library(devtools) states Error in library(devtools) : there is no package called ‘devtool

R-Studio - installing package knn error

I try to install the kknn package in R. It downloads the folder but whenever I use library(kknn) I get:
Error in library(kknn) : there is no package called ‘kknn’
install.packages("kknn") Installing package into ‘C:/Users/Ed/Documents/R/win-library/3.2’ (as ‘lib’ is unspecified) trying URL 'https://cran.rstudio.com/bin/windows/contrib/3.2/kknn_1.3.0.zip' Content type 'application/zip' length 321517 bytes (313 KB) downloaded 313 KB
package ‘kknn’ successfully unpacked and MD5 sums checked Warning in install.packages : cannot remove prior installation of package ‘kknn’
The downloaded binary packages are in C:\Users\Ed\AppData\Local\Temp\RtmpWClNdR\downloaded_packages
library(kknn) Error in library(kknn) : there is no package called ‘kknn’
Any suggestions?
Many thanks
Ed
You may try:
install.packages("kknn")
library(kknn)
Based on your edit:
goto R/win-library/3.2 folder, find the folder kknn and delete it. restart your R session then reinstall the package.
install.packages(kknn)
library(kknn)

Resources