Skip to content

Commit 28de4c7

Browse files
authored
perf: use attr() instead of attributes() for extracting single attribute (#1409)
1 parent e88a402 commit 28de4c7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

R/as_task_classif.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ as_task_classif.formula = function(x, data, id = deparse1(substitute(data)), pos
9292
assert_data_frame(data)
9393
assert_subset(all.vars(x), c(names(data), "."), .var.name = "formula")
9494

95-
if (!attributes(terms(x, data = data))$response) {
95+
if (!attr(terms(x, data = data), "response")) {
9696
stopf("Formula %s is missing a response", format(x))
9797
}
9898
tab = model.frame(x, data, na.action = "na.pass")

R/as_task_regr.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ as_task_regr.formula = function(x, data, id = deparse1(substitute(data)), label
8585
assert_data_frame(data)
8686
assert_subset(all.vars(x), c(names(data), "."), .var.name = "formula")
8787

88-
if (!attributes(terms(x, data = data))$response) {
88+
if (!attr(terms(x, data = data), "response")) {
8989
stopf("Formula %s is missing a response", format(x))
9090
}
9191
tab = model.frame(x, data, na.action = "na.pass")

0 commit comments

Comments
 (0)