[R-SIG-Finance] Enhancements to getSymbols.MySQL
Cedrick Johnson
cedrickjohnson at me.com
Mon May 14 20:48:33 CEST 2012
Hello-
Was upgrading my version of quantmod locally to the latest version on
r-forge and noticed that there's a couple things that could be
"improved" in the getSymbols.R file...
starting at line 418:
"getSymbols.MySQL" <- function(Symbols,env,return.class='xts',
db.fields=c('date','o','h','l','c','v','a'),
field.names = NULL,
user=NULL,password=NULL,dbname=NULL,...) {
is missing the ability to specify a remote host and port. Here's my fix
(lines 418-422):
"getSymbols.MySQL" <- function(Symbols,env,return.class='xts',
db.fields=c('date','o','h','l','c','v','a'),
field.names = NULL,
user=NULL,password=NULL,dbname=NULL,
host='localhost',port=3306,...) {
further down on line 443:
con <- dbConnect(MySQL(),user=user,password=password,dbname=dbname)
should be:
con <-
dbConnect(MySQL(),user=user,password=password,dbname=dbname,host=host,
port=port)
This fix enables me to specify (using setDefaults) hosts and port, as
shown below:
setDefaults(getSymbols.MySQL, user="wee", password="wee", host="myhost",
port=3306, dbname="histdata")
As it stands now, the setDefaults block above will generate a warning
message:
‘port’ was not set, possibly not a formal arg for ‘getSymbols.MySQL’
‘host’ was not set, possibly not a formal arg for ‘getSymbols.MySQL’
Thanks,
CJ
More information about the R-SIG-Finance
mailing list