File: test_preProcess_internals.R

package info (click to toggle)
r-cran-caret 7.0-1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 4,036 kB
  • sloc: ansic: 210; sh: 10; makefile: 2
file content (12 lines) | stat: -rw-r--r-- 639 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
context('Test preProcess internals')

test_that("handles situation when there's a single column per transformation", {
  # For the data below, the list of transformations used internally by
  # "preProcess" contains a single related attribute
  # for each transformation; namely, `method=list(center="y", ignore="x")`.
  # At certain point such setting didn't work properly.
  x <- data.frame(x=factor(c("a", "a")), y=c(1, 2), stringsAsFactors = TRUE)
  model <- caret::preProcess(method="center", x=x)
  preprocessed <- predict(model, x)
  expect_equal(preprocessed, data.frame(x=c("a", "a"), y=c(-0.5, 0.5), stringsAsFactors = TRUE))
})