I am trying to use R interfaced with MySQL. Present goal is that R should
calculate the 85% quantile of AvgSpeed for each LinieID. Looking through
documentation of the RMySQL Package, I guessed that dbApply would do the
trick due to this example

 

## compute quanitiles for each network agent
con <- dbConnect(MySQL(), group="vitalAnalysis")
res <- dbSendQuery(con, 
             "select Agent, ip_addr, DATA from pseudo_data order by Agent")
out <- dbApply(res, INDEX = "Agent", 
        FUN = function(x, grp) quantile(x$DATA, names=FALSE))
 

But when I try I get this:

 

> con = dbConnect(MySQL(),group="Speed")

> res <- dbSendQuery(con, "Select LinieID, AvgSpeed from speedlinietur order
by LinieID, AvgSpeed")

> out <- dbApply(res, INDEX = "LinieID",FUN = function(x, grp)
quantile(x$AvgSpeed, names=FALSE))

Error in mysqlDBApply(res, ...) : couldn't find function "dbGetConnection"

>

 

I saw in an earlier posting that:

There has been a change in function names in the new RMySQL 0.5-0 
version (also in the new ROracle and RSQLite). The reason is that 
the R-SIG-DB has agreed on a common interface to all databases, 
and as part of this new common interface, most functions have been 
renamed. The following simple name mapping may help you upgrade 
existing code to the new DBI: 

pre-DBI DBI 0.1-4 

…..

dbGetConnection = getConnection

…..

 

 

when I do this I get this error message

> dbGetConnection = getConnection

> out <- dbApply(res, INDEX = "LinieID",FUN = function(x, grp)
quantile(x$AvgSpeed, names=FALSE))

Error in if (what %in% set) structure(what, class = "connection") else NULL
: 

        argument is of length zero

>

 

Can anyone please help me

 

 

 

 

Jesper Runge Madsen

Ph.D.

Trafikforskningsgruppen

Institut for Samfundsudvikling og Planlægning

Aalborg Universitet

 <mailto:runge@plan.auc.dk> runge@plan.auc.dk

 


	[[alternative HTML version deleted]]


