I'm attempting to create my own function that uses the box cox transformation and returns all values of lambda in which the new data is normally distributed. Not sure where I have gone wrong. This is my code:
boxtran<-function(x){
lambda=seq(-5,5,1/10)
for(i in lambda) {
if (i!=0){
y<-(x^i-1)/i
}
if (i==0){
y<-log(x)
}
p<-ad.test(y)$p.value