getPotencialGainBySector | R Documentation |
getPotencialGainBySector(obj, regr)
obj |
|
regr |
##---- Should be DIRECTLY executable !! ----
##-- ==> Define data, use random,
##-- or do help(data=index) for the standard data sets.
## The function is currently defined as
function (obj, regr)
{
sectors <- getSectors(regr)
newObj <- new.env()
df <- data.frame()
for (sector in sectors) {
tickets <- getTicketsBySetor(sector, regr)
tickets <- tickets[!is.na(tickets)]
if (!is.na(tickets[1])) {
year <- obj[[as.character(tickets[1])]]$year
gain <- (1:nrow(obj[[as.character(tickets[1])]])) *
0
for (ticket in tickets) {
ds <- obj[[ticket]]
if (!is.null(ds)) {
for (idx in 1:nrow(ds)) {
gain <- gain + ds$gain
}
}
}
}
df <- rbind(df, data.frame(year, (gain/NROW(tickets)),
sector))
newObj[[sector]] <- df
}
names(df) <- c("year", "gain", "sector")
return(df)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.