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 <[email protected]>:
> 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
>
> [email protected]<mailto:[email protected]>
>
> ________________________________
> From: Jeff Newmiller <[email protected]>
> Sent: 08 May 2016 02:37:52
> To: Muhammad Bilal; [email protected]
> 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
> <[email protected]> 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
>
> [email protected]<mailto:[email protected]>
>
> [[alternative HTML version deleted]]
>
> ________________________________
>
> [email protected] 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]]
>
> ______________________________________________
> [email protected] 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]]
______________________________________________
[email protected] 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.