Error on train() function in R [closed]

2019-08-26 04:38发布

I am trying to learn from an online example and got stuck on one part. Particularly when i use train() function. I got an error saying train isn't a function. I did research and believe train is a function. The code i copied was : xgb_tree_model = train(SalePrice~., data=train, method="xgbTree", trControl=control, tuneGrid=grid, metric="rmsle", maximize = FALSE)

The site I am using is http://hamelg.blogspot.com/2016/09/kaggle-home-price-prediction-tutorial.html

1条回答
我命由我不由天
2楼-- · 2019-08-26 05:15

You can check step by step.

  1. Check if package is installed. Check using following command.

    find.package(c("caret"),lib.loc=NULL,quiet=FALSE, verbose = getOption("verbose"))

    it will show you package path if found else show you error message.

  2. If package is not installed, install it by using install.packages("caret") this will install package.

  3. Now load your caret package using library(caret)

  4. call train() function. Now you should not get error message.

查看更多
登录 后发表回答