我正在学习 R 中的 CARET 包,尝试在 Max Kuhn 的论文 "A Short Introduction to the caret Package" 中运行以下代码。在成功安装 CARET 后,当我运行以下代码时:
data(Sonar)
set.seed(107)
# The outcome data are needed, the percentage of data in the training set & the format of the results
inTrain <- createDataPartition(y = Sonar$Class,p = .75, list = FALSE)
str(inTrain)
我得到了如下错误,指出找不到createDataPartition()函数:
Error in createDataPartition(y = Sonar$Class, p = 0.75, list = FALSE) :
could not find function "createDataPartition"
> str(inTrain)
Error in str(inTrain) : object 'inTrain' not found
有什么想法吗?
最好的祝福,
麦克
library(caret)
- jjlcaret
库。在安装后使用该库的方法是将其加载到工作区中,以便R可以在特定会话中使用它。 - Eric Leung