0

Im getting an error when running this code for a box cox transformation

Error: mat[i,]<-p number of items to replace is not a multiple of replacement length

mat1<-matrix(Na,101,1)
for (i in 1:length(d4)) {
  d<-d4[[i]]
  p<-powerTransform(d$DBP)
  d$NEWDBP<-bcPower(d$DBP, p$lambda)
  results<-shapiro.test(d$NEWDBP)
  mat1[i,]<-(results$p.value)
  mat[i,]<-p
}
mat1

It is printing the results but giving me this error, the length of the set is 101, what am I doing wrong?

jogo
  • 12,469
  • 11
  • 37
  • 42
  • 3
    It would be easier for people to help you if you provide the data you are using. Please include the code to create d4. You can get this code using the command `dput(d4)`. – Kerry Jackson Oct 10 '18 at 18:23
  • From which package are the functions `powerTransform()` and `bcPower()` ? Please make your example reproducible, read https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example ... then edit your question! Eventually you can explore the object `p` using `str(p)` – jogo Oct 10 '18 at 18:29
  • Thanks guys, new to this site, will update soon. – Reagen Garbett Oct 10 '18 at 18:33

0 Answers0