Skip to content

Commit

Permalink
fix #354
Browse files Browse the repository at this point in the history
  • Loading branch information
mnwright committed Sep 26, 2018
1 parent 9490a26 commit 88356ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/ranger.R
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ ranger <- function(formula = NULL, data = NULL, num.trees = 500, mtry = NULL,
} else {
treetype <- 1
}
} else if (is.numeric(response) && is.vector(response)) {
} else if (is.numeric(response) && (is.null(ncol(response)) || ncol(response) == 1)) {
if (!is.null(classification) && classification && !probability) {
treetype <- 1
} else if (probability) {
Expand Down
12 changes: 12 additions & 0 deletions tests/testthat/test_interface.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,18 @@ test_that("Error if interaction of factor variable included", {
"Error: Only numeric columns allowed in interaction terms.")
})

test_that("Working if dependent variable has attributes other than names", {
iris2 <- iris
attr(iris2$Sepal.Width, "aaa") <- "bbb"
expect_silent(ranger(data = iris2, dependent.variable = "Sepal.Width"))
})

test_that("Working if dependent variable is matrix with one column", {
iris2 <- iris
iris2$Sepal.Width = scale(iris$Sepal.Width)
expect_silent(ranger(data = iris2, dependent.variable = "Sepal.Width"))
})

# Tibbles
# This is failing on Rdevel. Possible without suggesting tibble package?
# if (requireNamespace("tibble", quietly = TRUE)) {
Expand Down

0 comments on commit 88356ed

Please sign in to comment.