jvbraun / AlgDesign

Algorithmic Experimental Design by Robert E. Wheeler
12 stars 5 forks source link

optFederov: center=TRUE error with only one numeric variable #3

Closed tylermorganwall closed 8 years ago

tylermorganwall commented 8 years ago

drop=FALSE needs to be added to the subsetting of "data" in line 40 of FederovOpt.R. Otherwise, you get the error:

Error in apply(data[, numericColumn], 2, mean) : dim(X) must have a positive length

when the factorial design you input into optFederov only has one numeric variable.

FIX:

if (center) {
        means<-apply(data[,numericColumn],2,mean) #drop=FALSE needs to be added here
        data[,numericColumn]<-sweep(data[,numericColumn,drop=FALSE],2,means)
    }

You can recreate this with the design here:

factorialcoffee <- expand.grid(cost=as.numeric(c(1,2)),size=as.factor(c("Short","Grande","Venti")))
optFederov(~cost+size,data=factorialcoffee,nTrials=19,criterion = "D",nRepeats = 100,center=TRUE)
jvbraun commented 8 years ago

Thank you! I am currently working out how to proceed with maintenance.

tylermorganwall commented 8 years ago

Fixed with merge, closed