Path: blob/master/sandbox/extractStats.dev.R
1433 views
#' extract some stats from a portfolio list run with ROI via1#' \code{\link{optimize.portfolio}}2#'3#' This function will take everything in the objective_measures slot and \code{unlist} it.4#' This may produce a very large number of columns or strange column names.5#'6#' @param object list returned by optimize.portfolio7#' @param prefix prefix to add to output row names8#' @param ... any other passthru parameters9#' @seealso \code{\link{optimize.portfolio}}10#' @export11extractStats.optimize.portfolio.ROI <- function(object, prefix=NULL, ...) {1213trow<-c(out=object$out, object$weights)14result<-trow1516rnames<-c('out',paste('w',names(object$weights),sep='.'))17names(result)<-rnames18return(result)19}202122#' extract some stats from a portfolio list run with pso via23#' \code{\link{optimize.portfolio}}24#'25#' This function will take everything in the objective_measures slot and \code{unlist} it.26#' This may produce a very large number of columns or strange column names.27#'28#' @param object list returned by optimize.portfolio29#' @param prefix prefix to add to output row names30#' @param ... any other passthru parameters31#' @seealso \code{\link{optimize.portfolio}}32#' @export33extractStats.optimize.portfolio.pso <- function(object, prefix=NULL, ...) {3435trow<-c(out=object$out, object$weights)36result<-trow3738rnames<-c('out',paste('w',names(object$weights),sep='.'))39names(result)<-rnames40return(result)41}4243