gaa: Get, Apply, Assign

Description Usage Arguments Details Author(s) See Also Examples

View source: R/gaa.R

Description

Get data from environment, apply a FUNction, and re-assign the results.

Usage

1
2
  gaa(Symbols, FUN, ..., env = .GlobalEnv, store.to = env,
    invisible = FALSE)

Arguments

Symbols

names of xts objects

FUN

quoted or unquoted name of function to be applied

env

environment where data is stored (.GlobalEnv)

store.to

environment in which to store the results. By default it is the same as env

...

arguments to pass through to FUN

invisible

TRUE/FALSE. If true, nothing is returned, otherwise, Symbols will be returned

Details

FUN is intended to be something like Cl or to.daily as the results are stored in objects with the same name as Symbols

Author(s)

Garrett See

See Also

gsa, alignSymbols, PF

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
## Not run: 
s <- c('SPY', 'DIA', 'QQQ')
getSymbols(s, from='2011-01-01', to='2011-06-01', src='yahoo')

.cl <- new.env()
gaa(s, Cl, store.to=.cl)
head(.cl$SPY)

head(SPY)
gaa("SPY", adjustOHLC, symbol.name="SPY")
head(SPY)

## Need to loop for functions like adjustOHLC that use
## deparse(substitute(...)) if calling with more than 1 symbol
sapply(s[2:3], function(x) gaa(x, adjustOHLC, symbol.name=x))

## Clean up
rm('s', '.cl', 'SPY', 'DIA', 'QQQ')

## End(Not run)

qmao documentation built on May 2, 2019, 4:54 p.m.