1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| ## Importation des données
## chemin d'accès et nom du fichier source
dba <- "C:/Documents and Settings/Administrateur/Bureau/base donnée maxi-scooter/acc_2rm_idf_2008_CLV.xls"
dbb <- "C:/Documents and Settings/Administrateur/Bureau/base donnée maxi-scooter/acc_2rm_idf_2008_UR.xls"
dbc <- "C:/Documents and Settings/Administrateur/Bureau/base donnée maxi-scooter/acc_2rm_idf_2009_CLV.xls"
dbd <- "C:/Documents and Settings/Administrateur/Bureau/base donnée maxi-scooter/acc_2rm_idf_2009_UR.xls"
dbe <- "C:/Documents and Settings/Administrateur/Bureau/base donnée maxi-scooter/acc_2rm_idf_2010_CLV.xls"
dbf <- "C:/Documents and Settings/Administrateur/Bureau/base donnée maxi-scooter/acc_2rm_idf_2010_UR.xls"
## ouverture d'une connexion ODBC vers db
channela <- odbcConnectExcel(xls.file = dba)
channelb <- odbcConnectExcel(xls.file = dbb)
channelc <- odbcConnectExcel(xls.file = dbc)
channeld <- odbcConnectExcel(xls.file = dbd)
channele <- odbcConnectExcel(xls.file = dbe)
channelf <- odbcConnectExcel(xls.file = dbf)
acc2008_clv <- sqlFetch(channel = channela,sqtable = "CONCERTO")
acc2008_ur <- sqlFetch(channel = channelb,sqtable = "CONCERTO")
acc2009_clv <- sqlFetch(channel = channelc,sqtable = "CONCERTO")
acc2009_ur <- sqlFetch(channel = channeld,sqtable = "CONCERTO")
acc2010_clv <- sqlFetch(channel = channele,sqtable = "CONCERTO")
acc2010_ur <- sqlFetch(channel = channelf,sqtable = "CONCERTO")
odbcClose(channela)
odbcClose(channelb)
odbcClose(channelc)
odbcClose(channeld)
odbcClose(channele)
odbcClose(channelf)
##Fusion des tables
# par colonnes
acc2008=merge(acc2008_clv,acc2008_ur,by=c("Org/Unité/PV","Date","Heure"),all=F)
acc2009=merge(acc2009_clv,acc2009_ur,by=c("Org/Unité/PV","Date","Heure"),all=F)
acc2010=merge(acc2010_clv,acc2010_ur,by=c("Org/Unité/PV","Date","Heure"),all=F)
# par lignes
acc08_10=rbind(acc2008,acc2009,acc2010) |
Partager