[R] Compress string memCompress/Decompress
Seth Falcon
seth at userprimary.net
Mon Jul 12 01:13:24 CEST 2010
On Sun, Jul 11, 2010 at 11:31 AM, Matt Shotwell <shotwelm at musc.edu> wrote:
> On Fri, 2010-07-09 at 20:02 -0400, Erik Wright wrote:
>> Hi Matt,
>>
>> This works great, thanks!
>>
>> At first I got an error message saying BLOB is not implemented in RSQLite. When I updated to the latest version it worked.
>
> SQLite began to support BLOBs from version 3.0.
And RSQLite began supporting BLOBs only just recently :-)
See the NEWS file for details.
Below is a minimal example of how you might use BLOBs:
db <- dbConnect(SQLite(), dbname = ":memory:")
dbGetQuery(db, "CREATE TABLE t1 (name TEXT, data BLOB)")
z <- paste("hello", 1:10)
df <- data.frame(a = letters[1:10],
z = I(lapply(z, charToRaw)))
dbGetPreparedQuery(db, "insert into t1 values (:a, :z)", df)
a <- dbGetQuery(db, "select name from t1")
checkEquals(10, nrow(a))
a <- dbGetQuery(db, "select data from t1")
checkEquals(10, nrow(a))
a <- dbGetQuery(db, "select * from t1")
checkEquals(10, nrow(a))
checkEquals(2, ncol(a))
checkEquals(z, sapply(a$data, rawToChar))
dbDisconnect(db)
--
Seth Falcon | @sfalcon | http://userprimary.net/
More information about the R-help
mailing list