wiki:CookBook Import

back to first page ..
back to Recipes for EDA CookBook R

Import various types of files

How to import dbf files Use the library "foreign" with R and write in the R console

library(foreign)
read.dbf("COAST.dbf")

getting from excel

http://learnr.wordpress.com/2009/10/06/export-data-frames-to-multi-worksheet-excel-file/

library(RODBC)
channel<-odbcConnectExcel("C:/Documents and Settings/cedric/Mes documents/Migrateur/Publications/seudre_et_charente/data.xls")
sqlTables(channel)
f1 <- sqlFetch(channel, "feuil1")
#sh1 <- sqlQuery(channel, "select * from [feuil1$]")
odbcClose(channel)

writing to excel (do not forget the readOnly argument)

library(RODBC)
channel<-odbcConnectExcel("C:/Documents and Settings/cedric/Mes documents/Migrateur/Publications/seudre_et_charente/treated_data.xls",readOnly = FALSE)
sqlSave(channel, dat=df,tablename=paste("sorties",format(Sys.time(), "%M%d%Y"),sep=""))
odbcCloseAll()
Last modified 15 years ago Last modified on Oct 7, 2010 1:49:34 PM