R/collect.optimx.R

Defines functions collect.optimx

Documented in collect.optimx

collect.optimx <-
function(res,opt="min"){ 

# reorder dataframe for best solution
if(opt=="min"){
  res <- res[order(res$value,decreasing=FALSE),]
}
if(opt=="max"){
  res <- res[order(res$value,decreasing=TRUE),]
}
 
# index for value
val <- which(colnames(res)=="value") 
# index for pars
pars <- 1:(val-1)

# extract best solution
out <- list(out.list=res,
            par=res[1,pars],
            value=res[1,val]
            )
return(invisible(out))

}

Try the Synth package in your browser

Any scripts or data that you put into this service are public.

Synth documentation built on June 7, 2023, 5:23 p.m.