问题
I have a user defined function in SQLite (an aggregator that calculates the product) and it works fine outside R. But I'm on a Mac some of the time, which requires the MacPorts version of SQLite3 if you'd like to add your own functions/extensions.
Can I pick which SQLite3 that RSQLite loads? I don't see anything in the SQLite documentation.
Also, MacPorts appears to change my sqlite3
link to the MacPorts installed SQLite3:
mbp:~ richard$ which sqlite3
/opt/local/bin/sqlite3
But if I want to load the extension in SQLite3, I have to explicitly can the MacPorts version, like this:
mbp:~ richard$ /opt/local/bin/sqlite3 temp.sqlite
Is writing my own SQLite functions and combining them with R a lost cause? Thanks!
回答1:
Have you installed and loaded the RSQLite.extfuns package? It has a single function which loads the available functions:
db <- dbConnect(SQLite(), dbname = ":memory:")
init_extensions(db)
By default these are the Healy extensions.
来源:https://stackoverflow.com/questions/4173019/load-macports-sqlite3-when-using-rsqlite-library