[R] large list from mdb.get - change labled atomic to double

stephen sefick ssefick at gmail.com
Mon Aug 17 01:49:09 CEST 2009

I have a microsoft database that I have read in that is a list of
dataframes processed by mdb.get.  I am trying to read this into GRASS
gis and need to change the labled atomic vectors to double precision-
especially the coord.x coord.y.  Now is there a way to check for
classes and then change them inside of a for loop.  This is the code I
am using at the moment.

# Read all tables in the Microsoft Access database blabla.mdb
#   perhaps better change to Locale in which the .mdb file was
#   generated to avoid that accented table column names are
#   getting lost.file first
#mdbtools also has to be working
d <- mdb.get('/Users/sefick/Desktop/FtBragg_GeoDataBase_AuburnUNV.mdb')
f <- list()
for(i in 1:length(d)){
	a <- as.integer(d[[i]][,1])
	b <- cbind(a, d[[i]])
	colnames(b)[1] <- "ID"
	f[[i]] <- b
names(f) <- names(d)

#create database in sqlite3 before using this script
drv <- dbDriver("SQLite")
con <- dbConnect(drv, dbname = '/Users/sefick/Desktop/GISbragg.db')
name <- names(d)
for(z in 1:length(f)) dbWriteTable(con, name[z], f[[z]], overwrite=TRUE)

Stephen Sefick

Let's not spend our time and resources thinking about things that are
so little or so large that all they really do for us is puff us up and
make us feel like gods.  We are mammals, and have not exhausted the
annoying little problems of being mammals.

								-K. Mullis

More information about the R-help mailing list