This file is indexed.

/usr/share/doc/r-cran-caret/tests/testthat/test_BoxCox.R is in r-cran-caret 6.0-78+dfsg1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
context('Box Cox transformations')

###################################################################
## Generate data and do BC using the source function to get 
## expected results

library(MASS)

set.seed(1)
dat <- matrix(runif(30), ncol = 3)
dat[,1] <- exp(dat[,1])
colnames(dat) <- paste0("x", 1:3)

exp_lambdas <- rep(NA, 3)
for(i in 1:ncol(dat)) {
  tmp <- as.data.frame(dat)[,i,drop = FALSE]
  names(tmp)[1] <- "x"
  tmp_bc <- boxcox(x ~ 1, data = tmp, plotit = FALSE, lambda = seq(-2, 2, by = .1))
  exp_lambdas[i] <- tmp_bc$x[which.max(tmp_bc$y)]
}

check_BoxCox <- function(x, expected = NULL) {
  pp1 <- preProcess(x, method = "BoxCox")
  obs_lambdas1 <- unlist(lapply(pp1$bc, function(x) x$lambda))
  names(obs_lambdas1) <- NULL
  expect_equal(obs_lambdas1, expected)
}

check_BoxCox(dat, expected = exp_lambdas)
check_BoxCox(as.data.frame(dat), expected = exp_lambdas)