r - preprocess center and scale produces an error -
from caret package
i have vector
library(caret) a<-c(-1,1-1,3,2,-2,-1,5,2,3,-3)
i preprocess center , scale above vector, have tried vector, data.frame , matrix. doing using preprocess function not manually taking mean end substracting data etc. missing something?
#preprocess(a, method = c("center", "scale")) #error en apply(x, 2, mean, na.rm = na.remove) : #dim(x) must have positive length
thank
data frame works
library(caret) test <- preprocess(data.frame(a = c(-1,1-1,3,2,-2,-1,5,2,3,-3))) predict(test, data.frame(a = c(-1,1-1,3,2,-2,-1,5,2,3,-3))) # #1 -0.6994725 #2 -0.3108767 #3 0.8549108 #4 0.4663150 #5 -1.0880683 #6 -0.6994725 #7 1.6321024 #8 0.4663150 #9 0.8549108 #10 -1.4766641
Comments
Post a Comment