0

I am using R 3.4.3 and am unable to install the caret package (Error in install.packages(caret) : object 'caret' not found). I have tried other repositories and CRAN mirrors. I have tried installing github and remotes and devtools with no luck. Any ideas on how I can install this package? I have tried install.packages("caret") with the following error message: Warning in install.packages("caret") : 'lib = "C:/Program Files/R/R-3.4.3/library"' is not writable Error in install.packages("caret") : unable to install packages. I have internet connectivity and have tried installing from the menu without luck.

K. Jeary
  • 11
  • 3
  • 6
    `install.packages("caret")` – patL Feb 15 '18 at 11:32
  • Try to find it through the menu. – gsa Feb 15 '18 at 11:33
  • Installing from CRAN from command-line or GUI should work, but if for whatever reason it doesn't (might be your intranet, or connectivity, or network security), you can download the tarball (with wget or browser) then proceed as per [Install R Packages without internet](https://stackoverflow.com/questions/10528630/install-r-packages-without-internet). See also [How should I deal with “package 'xxx' is not available (for R version x.y.z)” warning? ](https://stackoverflow.com/questions/25721884/how-should-i-deal-with-package-xxx-is-not-available-for-r-version-x-y-z-wa) for fallbacks. – smci Feb 15 '18 at 11:39
  • For which OS and OS version? I presume you tried the obvious things like restarting R, rebooting. – smci Feb 15 '18 at 11:41
  • 2
    This shouldn't be downvoted or closed. It's a new-user error that could happen to all of us. – smci Feb 15 '18 at 12:03
  • I appreciate your answers but putting quotes around caret has not helped. > install.packages("caret") Warning in install.packages("caret") : 'lib = "C:/Program Files/R/R-3.4.3/library"' is not writable Error in install.packages("caret") : unable to install packages – K. Jeary Feb 16 '18 at 15:25

2 Answers2

3

You need " quotes

install.packages("caret")

and to use it

library(caret)
smci
  • 32,567
  • 20
  • 113
  • 146
unnic
  • 101
  • 2
  • 9
  • 2
    Note that the reason the second command gets away with not needing compulsory quotes is because caret has been loaded as an object on the searchpath. (You can still write `library("caret")` if you want) – smci Feb 15 '18 at 12:05
1

Because you missed the quotes around "caret"

install.packages("caret") # RIGHT - use a string name
install.packages(caret)   # WRONG - it thinks caret is some string variable containing the name of the actual package

OLD ANSWER - Installing from CRAN from command-line or GUI should work, but if for whatever reason it doesn't (might be your intranet, or connectivity, or network security), you can... - Download the tarball (with wget/ browser/ ftp) then proceed as per Install R Packages without internet - See also How should I deal with “package 'xxx' is not available (for R version x.y.z)” warning? for fallbacks (compile from source, use older version, etc).

smci
  • 32,567
  • 20
  • 113
  • 146