[R] Creating a new Access database with R

Barry Rowlingson b.rowlingson at lancaster.ac.uk
Thu Feb 11 19:57:46 CET 2010


On Thu, Feb 11, 2010 at 6:23 PM, Dieter Menne
<dieter.menne at menne-biomed.de> wrote:
>
>
> Paul- wrote:
>>
>> As a workaround, you can keep an empty mdb file on your filesystem. When
>> you need a new database, you can copy and rename the empty file.
>>
>>
>
> Creating a new database is not part of (R)ODBC because there are too many
> differences between implementations. You you use some RDCOM method to do
> that, though.

 Create an empty mdb file in the usual way, then read it into R using
a binary file connection, save it as an R object. To create, spew the
raw bytes back out to another connection. Something like:

mdb = readBin("test1.mdb",what="raw",n=70000)
 length(mdb)
[1] 65536

Ooh, 64kbytes. If that's too big, run length encoding will shrink it somewhat:

> rle(mdb)
Run Length Encoding
  lengths: int [1:3953] 1 1 2 1 1 1 1 1 1 1 ...
  values : raw [1:3953] 00 01 00 53 ...

 However, I just created two via the MS ODBC dialog, and they aren't
identical. They are wildly different. I suspect it's just creation
dates and times in the system tables. You should be okay.

Barry



More information about the R-help mailing list