stephen sefick
2009-Aug-16 23:49 UTC
[R] large list from mdb.get - change labled atomic to double
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. library(Hmisc) # 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 Sys.setlocale('LC_ALL','C') Sys.setenv(PATH=paste(Sys.getenv('PATH'),'/sw/bin',sep=':')) 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 library(RSQLite) 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) dbDisconnect(con) -- 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