search for: dfreturns

Displaying 2 results from an estimated 2 matches for "dfreturns".

2006 Mar 07
2
(newbie) Accessing the pieces of a 'by' object
...ecuase of the need to pass weighted.mean a weights vector. I tried the by() function, but now I don't know how to coerce the returned object into a matrix so that I can reshape it. > fvs_weighted.mean <- function(y) weighted.mean(y$F3MRet, y$IndexWeight, na.rm=T); > tmp_byRet <- by(dfReturns, list(dfReturns$Quarter,dfReturns$Year,dfReturns$Ranking), fvs_weighted.mean); And various other ways to get the tmp_byRet object into a matrix were tried, eg. unlist(), a loop like this: dfRet <- data.frame(tmp_byRet); for(i in 1:dim(dfRet)[2]){ dfRet[ ,i] <- as.vector(dfRe...
2006 Mar 08
0
survival
...ecuase of the need to pass weighted.mean a weights vector. I tried the by() function, but now I don't know how to coerce the returned object into a matrix so that I can reshape it. > fvs_weighted.mean <- function(y) weighted.mean(y$F3MRet, y$IndexWeight, na.rm=T); > tmp_byRet <- by(dfReturns, list(dfReturns$Quarter,dfReturns$Year,dfReturns$Ranking), fvs_weighted.mean); And various other ways to get the tmp_byRet object into a matrix were tried, eg. unlist(), a loop like this: dfRet <- data.frame(tmp_byRet); for(i in 1:dim(dfRet)[2]){ dfRet[ ,i] <- as.vector(dfRe...