sqlite - Call R functions from sqldf queries -


is there way call r functions sqldf queries? e.g.

sqldf("select paste('hello', 'world')") 

or, there way define custom functions or stored procedures within sqlite engine behind sqldf? (i using sqldf plain old in-memory r data frames; i'm not connecting actual databases.)

1) existing functions first make sure function want not available. example code in question directly supported in sql already:

> sqldf("select 'hello' || ' ' || 'world' ")   'hello' || ' ' || 'world' 1               hello world 

2) rsqlite.extfuns 1 has sql functions sqlite's version of sql plus large number of user defined functions out of box in rsqlite.extfuns package (which automatically loaded sqldf).

3) other loadable extensions functions in existing sqlite loadable extensions can loaded via sqlite sql function load_extension(). e.g. see these extensions

4) custom functions custom functions can added sqlite must written in c.

5) postgresql & sqldf sqldf supports not sqlite h2, postgresql , mysql. postgresql particularly powerful in respect. see this link postgresql documentation see pl/r , r embedded postgres package.

6) h2 & sqldf h2 database supported sqldf. sqlite h2 included right in rh2 driver r package don't have install separate database; however, have install java. has builtin sha256 hash function (called hash).

7) mix sqldf & r sql , r can mixed this:

library(digest) transform(sqldf("select * bod"), digest = sapply(demand, digest)) 

8) other see so question , answers

update: added info on h2.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -