0

Good day everyone, I tried installing the caret package in R with the following codes but I am having an error stating that Stringi is not found despite trying to install that, I got a failed attempt.

Also, I tried to partition my data using the create createDataPartition function but I got the error "**could not find function createDataPartition

The codes I used:

install.packages("caret")

library(caret)

install.packages("stringi")

library(stringi)

The results are below:

**install.packages("caret")**
*Installing package into ‘C:/Users/Anuli/OneDrive - The University of Texas-Rio Grande Valley/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
Warning in install.packages :
  package ‘CARET’ is not available for this version of R
A version of this package for your version of R might be available elsewhere,
see the ideas at
https://cran.r-project.org/doc/manuals/r-patched/R-admin.html#Installing-packages
Warning in install.packages :
  Perhaps you meant ‘caret’ ?*

**library(caret)**
*Loading required package: ggplot2
Loading required package: lattice
Error: package or namespace load failed for ‘caret’ in library.dynam(lib, package, package.lib):
 DLL ‘stringi’ not found: maybe not installed for this architecture?*

**install.packages("stringi")**
*Installing package into ‘C:/Users/Anuli/OneDrive - The University of Texas-Rio Grande Valley/Documents/R/win-library/4.1’
(as ‘lib’ is unspecified)
trying URL 'https://cran.rstudio.com/bin/windows/contrib/4.1/stringi_1.7.6.zip'
Content type 'application/zip' length 16449819 bytes (15.7 MB)
downloaded 15.7 MB
package ‘stringi’ successfully unpacked and MD5 sums checked
Warning in install.packages :
  cannot delete reparse point 'C:\Users\Anuli\OneDrive - The University of Texas-Rio Grande Valley\Documents\R\win-library\4.1/stringi/libs/x64', reason 'There is a mismatch between the tag specified in the request and the tag present in the reparse point'
Warning in install.packages :
  cannot remove prior installation of package ‘stringi’
Warning in install.packages :
  cannot delete reparse point 'C:\Users\Anuli\OneDrive - The University of Texas-Rio Grande Valley\Documents\R\win-library\4.1/stringi/libs/x64', reason 'There is a mismatch between the tag specified in the request and the tag present in the reparse point'
Warning in install.packages :
  restored ‘stringi’
The downloaded binary packages are in
    C:\Users\Anuli\AppData\Local\Temp\RtmpyqAGs4\downloaded_packages*

**library(stringi)**

*Error: package or namespace load failed for ‘stringi’ in library.dynam(lib, package, package.lib):
 DLL ‘stringi’ not found: maybe not installed for this architecture?*

As a result of the stringi not found error, I am unable to split my data:

myData$cyl <- as.factor(myData$cyl)

sapply(myData, is.factor)
  mpg   cyl  disp    hp  drat    wt  qsec    vs    am  gear  carb 
FALSE  TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE 

set.seed(1)

index <- createDataPartition(myData$cyl, p=0.75, list=FALSE)
Error in createDataPartition(myData$cyl, p = 0.75, list = FALSE) : 
  could not find function "createDataPartition"
Dmitriy Zub
  • 1,398
  • 8
  • 35
  • You say you used the code `install.packages("caret")`, but you get a warning that "package ‘CARET’ is not available... Perhaps you meant ‘caret’ ?". Are you sure you used `install.packages("caret")` not `install.packages("CARET")`? R is case-sensitive. – Gregor Thomas Mar 30 '22 at 17:03
  • Or try `caret::createDataPartition()`? – Quinten Mar 30 '22 at 17:16
  • Oooh, I'm also noticing that the messages say "Installing package into ‘C:/Users/Anuli/OneDrive ...". OneDrive often makes things weird for accessing packages. I'd strongly suggest [following the steps in this answer](https://stackoverflow.com/a/39056424/903061) to create your package library (the folder where R installs packages) on your local drive, not in OneDrive. – Gregor Thomas Mar 30 '22 at 18:07
  • 1
    Thank you so much guys! @Gregor Thomas, I followed the steps as you suggested and I created the package library on my local drive as opposed to the OneDrive. – Anulika Azubike Apr 05 '22 at 00:39
  • Glad to hear it worked! – Gregor Thomas Apr 05 '22 at 01:46

0 Answers0