{"action":"closed","issue":{"url":"https://api.github.com/repos/topepo/caret/issues/849","repository_url":"https://api.github.com/repos/topepo/caret","labels_url":"https://api.github.com/repos/topepo/caret/issues/849/labels{/name}","comments_url":"https://api.github.com/repos/topepo/caret/issues/849/comments","events_url":"https://api.github.com/repos/topepo/caret/issues/849/events","html_url":"https://github.com/topepo/caret/issues/849","id":301515841,"number":849,"title":"extractProb Incorrect dimensions when X Has One Column","user":{"login":"ray-p144","id":16431187,"avatar_url":"https://avatars0.githubusercontent.com/u/16431187?v=4","gravatar_id":"","url":"https://api.github.com/users/ray-p144","html_url":"https://github.com/ray-p144","followers_url":"https://api.github.com/users/ray-p144/followers","following_url":"https://api.github.com/users/ray-p144/following{/other_user}","gists_url":"https://api.github.com/users/ray-p144/gists{/gist_id}","starred_url":"https://api.github.com/users/ray-p144/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ray-p144/subscriptions","organizations_url":"https://api.github.com/users/ray-p144/orgs","repos_url":"https://api.github.com/users/ray-p144/repos","events_url":"https://api.github.com/users/ray-p144/events{/privacy}","received_events_url":"https://api.github.com/users/ray-p144/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-03-01T18:44:50Z","updated_at":"2018-03-01T22:58:11Z","closed_at":"2018-03-01T22:58:11Z","author_association":"NONE","body":"When using the `extractProb` function on a model that was trained with only one column in `X`, the following error is thrown:\r\n```\r\nError in newdata[, object$method$center, drop = FALSE] : \r\n  incorrect number of dimensions\r\n```\r\n\r\nThe problem seems to be caused by this [line](https://github.com/topepo/caret/blob/0e6aa496bf9f01b478ceca596c0d5a1a21f1497f/pkg/caret/R/extractProb.R#L23) when the `data.frame` is turned into a `vector`.\r\n\r\nMinimum reproducible example:\r\n```\r\nlibrary(caret)\r\nTrainData <- data.frame(x = runif(100))\r\nTrainClasses <- sample(c(\"Y\", \"N\"), 100, TRUE)\r\nfit <- train(TrainData, TrainClasses,\r\n             method = \"glm\",\r\n             preProcess = c(\"center\", \"scale\"),\r\n             trControl = trainControl(method = \"cv\", classProbs = TRUE))\r\nextractProb(list(fit))\r\n```\r\n\r\nI would suggest adding the argument `drop = FALSE` like the `extractPrediction` function has in this [line](https://github.com/topepo/caret/blob/0e6aa496bf9f01b478ceca596c0d5a1a21f1497f/pkg/caret/R/extractPrediction.R#L15)"}}
{"actor":{"display_login":"topepo"}}