1
$\begingroup$

I am trying to follow up the example code in the "Building Predictive Models in R Using the caret Package" paper from Max Kuhn[1].

Here is the part of the code:

library("caret")
set.seed(1)
inTrain <- createDataPartition(mutagen, p = 3/4, list = FALSE)

However, after the following,

trainDescr<-descr[ inTrain, ]

Error: object 'descr' not found

I get the "Error: object 'descr' not found" message. Looks like 'descr' is not recognized. Can anyone tell me how to fix this please?

[1]: Kuhn, M. (2008),
"Building Predictive Models in R Using the caret Package,"
Journal of Statistical Software, November, Volume 28, Issue 5.
link

$\endgroup$
  • $\begingroup$ I agree, there is no object named 'descr'. I'm betting that it is an object in Kuhn's example and you need to translate it to yous. Perhaps you need mutagen[inTrain, ]? $\endgroup$ – Russ Lenth Sep 1 '14 at 0:37
  • $\begingroup$ Please give a complete reference. What did you expect descr to be? $\endgroup$ – Glen_b -Reinstate Monica Sep 1 '14 at 0:38
  • $\begingroup$ I've included the reference. $\endgroup$ – Glen_b -Reinstate Monica Sep 1 '14 at 0:45
7
$\begingroup$

Your problem is you didn't put the data into the variable descr that the code you ran assumed would be there.

Read the last paragraph of Sec. 2 of the paper; it says what should be in descr and how to get it:

The descriptor data are contained in an R data frame names descr and the outcome data are in a factor vector called mutagen with levels "mutagen" and "nonmutagen". These data are available from the package website http://caret.R-Forge.R-project.org/

That page leads you to a github page that has a link to the data (it's not so easy to spot, but it's there).

descr is here: http://topepo.github.io/caret/descr.RData

mutagen is here: http://topepo.github.io/caret/mutagen.RData

$\endgroup$
2
$\begingroup$

The package QSARdata also contains the mutagen data set. The variables are named Mutagen_Dragon and Mutagen_Outcome, so you need to rename them descr and mutagen respectively.

Unfortunately, both these data sets have the same problem: The example code in the good old paper of Kuhn does not work. When I call findCorrelation(), I get the error message 'missing value where TRUE/FALSE needed'.

Kuhn reports the descr table contains 1576 columns, whereas our data set contains 1579. Khun himself later suggested this fix:

zv = apply(trainDescr, 2, function(x) length(unique(x))==1)
sum(zv) # there are 3 zero-variance columns; remove them
which(zv)
trainDescr = trainDescr[ ,!zv]
testDescr = testDescr[ ,!zv]
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.