Skip to content
Back to formatted view

Raw Message

Message-ID: <46FE64FB.606@mail.nih.gov>
Date: 2007-09-29T14:45:15Z
From: Sean Davis
Subject: Storing data.frame attirbutes in SQL through DBI
In-Reply-To: <dba1e14b0709290730u552239d5y7074f9fd5758751e@mail.gmail.com>

Iago Mosqueira wrote:
> Hello,
>
> What would be the best way of storing some extra attributes of a
> data.frame on an SQLite database? Am I forced to use a separate table
> for this?
>   

That is probably the best way to do it, yes.  I would imagine making a 
"saveDataFrame" function which would accept a data frame, pull off the 
attributes that you want to save, write them into a separate table, then 
save the data in the data frame.  You might need a third table to store 
the name or id of the data frame.  You would, of course, need a 
"loadDataFrame" function as well as a "deleteDataFrame" function.  If 
you can abstract all the SQL into a function, then using a three-table 
structure for a data frame becomes quite feasible.

You could also look into using something like HDF5 (see the HDF5 package 
on cran--I have never used it, though) or the ncdf package, which reads 
and writes netcdf files.  Both of these provide a way of writing "rich" 
data files.

Sean