I have recently started using SQLite to store my raw biological data (I have several forms of raw data output and find it is a very useful way of querying and linking tables relating to the same trial). I would now like to pull out the raw data from across different files, combine it into a dataframe and then work on it (for example, I want to turn my dates into Julian dates and create new variables based on those I already have).
This link gave an excellent example of how to combine files that are in the same database:
Importing FIles with Extension .sqlite into R
and I managed to use this to create the dataframe I wanted. However (and here is where my lack of experience shows) the resulting dataframe didn't have recognisable headers:
> con <- dbConnect(drv, dbname="...PreliminaryFlightTrial.db")
> tables <- dbListTables(con)
> tables.excl <- tables[tables != "sqlite_sequence"]
> lDataFrames <- vector("list", length=length(tables.excl))
> for (i in seq(along=tables.excl)) {
+ lDataFrames[[i]] <- dbGetQuery(conn=con, statement=paste("SELECT * FROM '", tables.excl[[i]], "'", sep=""))
+ }
> names(lDataFrames)
NULL
I'd be really grateful if someone could point out my error. I did try adding header=T and the code ran but I still couldn't access the names:
for (i in seq(along=tables.excl)) { + DataFrames[[i]] <- dbGetQuery(conn=con, statement=paste("SELECT * FROM '", tables.excl[[i]], "'", sep="",header=T)) + } names(DataFrames) NULL
I did try googling but didn't get very far - maybe I am searching the wrong terms?
Many thanks