[R] trainControl and train functions are not found in caret package

Muhammad Bilal Muhammad2.Bilal at live.uwe.ac.uk
Sun May 8 17:31:01 CEST 2016


Thanks you very much.


The issue resolved by just upgrading the R and R studio to their latest versions. All the packages are now successfully installed. Henceforth, the code runs absolutely okay.


--
Muhammad Bilal
Research Fellow and Doctoral Researcher,
Bristol Enterprise, Research, and Innovation Centre (BERIC),
University of the West of England (UWE),
Frenchay Campus,
Bristol,
BS16 1QY

muhammad2.bilal at live.uwe.ac.uk<mailto:olugbenga2.akinade at live.uwe.ac.uk>


________________________________
From: ruipbarradas at sapo.pt <ruipbarradas at sapo.pt>
Sent: 08 May 2016 11:57:22
To: Muhammad Bilal
Cc: Jeff Newmiller; r-help at r-project.org
Subject: Re: [R] trainControl and train functions are not found in caret package


Hello,

Works with me, but I'm using R v 3.3.0. Note that your version of R is over 1 year old, try updating it.

install.packages("caret")
install.packages("e1071")

library(caret)
library(e1071)

set.seed(100)

tr.control <- trainControl(method="cv", number=10)

class(tr.control)
[1] "list"

Hope this helps,

Rui Barradas



Citando Muhammad Bilal <Muhammad2.Bilal at live.uwe.ac.uk<mailto:Muhammad2.Bilal at live.uwe.ac.uk>>:

Firstly, many thanks for kind consideration.

***I wrote the following R code:
install.packages("caret")
install.packages("e1071")

library(caret)
library(e1071)

set.seed(100)

tr.control <- trainControl(method="cv", number=10)
Error: could not find function "trainControl"

cp.grid <- expand.grid(.cp = (0:10)*0.001)

tr_m <- train(project_delay ~ project_lon + project_lat + project_duration + sector + contract_type + capital_value, data = trainPFI, method="rpart", trControl=tr.control, tuneGrid = cp.grid)
Error: could not find function "train"

I hope this will explain the situation I am facing right now.

***Below are the details of session info:

sessionInfo()

R version 3.2.0 (2015-04-16)
Platform: i386-w64-mingw32/i386 (32-bit)
Running under: Windows 7 (build 7601) Service Pack 1

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] tcltk     stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] e1071_1.6-7      lattice_0.20-31  caTools_1.17.1   rpart.plot_1.5.3 rpart_4.1-10
[6] XML_3.98-1.4     maps_3.1.0       plotrix_3.6-1    xlsx_0.5.7       xlsxjars_0.6.1
[11] rJava_0.9-8      sqldf_0.4-10     RSQLite_1.0.0    DBI_0.3.1        gsubfn_0.6-6
[16] proto_0.3-10     ggplot2_2.1.0

loaded via a namespace (and not attached):
[1] codetools_0.2-11 digest_0.6.9     scales_0.4.0     grid_3.2.0       bitops_1.0-6
[6] stringr_1.0.0    munsell_0.4.3    nnet_7.3-9       labeling_0.3     foreach_1.4.3
[11] iterators_1.0.8  chron_2.3-47     MASS_7.3-40      plyr_1.8.3       stringi_1.0-1
[16] magrittr_1.5     reshape2_1.4.1   gtable_0.2.0     colorspace_1.2-6 tools_3.2.0
[21] nlme_3.1-120     class_7.3-12     Rcpp_0.11.6



I even tried loading the caret package using require() function but no success.

Many Thanks and

Kind Regards


--
Muhammad Bilal
Research Fellow and Doctoral Researcher,
Bristol Enterprise, Research, and Innovation Centre (BERIC),
University of the West of England (UWE),
Frenchay Campus,
Bristol,
BS16 1QY

muhammad2.bilal at live.uwe.ac.uk<mailto:muhammad2.bilal at live.uwe.ac.uk><mailto:olugbenga2.akinade at live.uwe.ac.uk><mailto:olugbenga2.akinade at live.uwe.ac.uk>>


________________________________
From: Jeff Newmiller <jdnewmil at dcn.davis.ca.us<mailto:jdnewmil at dcn.davis.ca.us>>
Sent: 08 May 2016 02:37:52
To: Muhammad Bilal; r-help at r-project.org<mailto:r-help at r-project.org>
Subject: Re: [R] trainControl and train functions are not found in caret package

Reproducible example? At least whatever you did... and the output of sessionInfo().

Did you use library function to load it into memory?
--
Sent from my phone. Please excuse my brevity.

On May 7, 2016 5:40:26 PM PDT, Muhammad Bilal <Muhammad2.Bilal at live.uwe.ac.uk<mailto:Muhammad2.Bilal at live.uwe.ac.uk>> wrote:

Hi All,


Whilst using 'trainControl' and 'train' functions in R studio, an error is raised stating that the functions are not found.


I tried installing the caret function a few times, but the error persists.


Can anyone guide me how to access these functions.


Many Thanks and


Kind Regards

--
Muhammad Bilal
Research Fellow and Doctoral Researcher,
Bristol Enterprise, Research, and Innovation Centre (BERIC),
University of the West of England (UWE),
Frenchay Campus,
Bristol,
BS16 1QY

muhammad2.bilal at live.uwe.ac.uk<mailto:muhammad2.bilal at live.uwe.ac.uk><mailto:olugbenga2.akinade at live.uwe.ac.uk><mailto:olugbenga2.akinade at live.uwe.ac.uk>>


[[alternative HTML version deleted]]

________________________________

R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read
the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

        [[alternative HTML version deleted]]

______________________________________________
R-help at r-project.org<mailto:R-help at r-project.org> mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.htmland provide commented, minimal, self-contained, reproducible code.



	[[alternative HTML version deleted]]



More information about the R-help mailing list