diff --git a/RellenarOVBD.R b/RellenarOVBD.R index 5181198..55459f6 100644 --- a/RellenarOVBD.R +++ b/RellenarOVBD.R @@ -81,13 +81,17 @@ rownames(upd.samples)<-(nsamples+1):(nsamples+nrow(upd.samples)) %>% as.characte sqlSave(dta, upd.samples, tablename="SAMPLES", append = T) ## Añadir datos clínicos modificados a la base de datos -upd.samples<-read.xlsx("QueryOV.xlsx", sheet = "CLINICS",detectDates = T) +upd.clinics<-read.xlsx("QueryOV.xlsx", sheet = "CLINICS",detectDates = T) ovid.mod<-upd.clinics$OVID[upd.clinics$OVID %in% (sqlFetch(dta, "CLINICS") %>% pull(OVID))] rnames<-sqlFetch(dta, "CLINICS") %>% filter(OVID %in% ovid.mod) %>% rownames clinics.mod<-upd.clinics %>% filter(OVID %in% ovid.mod) %>% select(-NHC) rownames(clinics.mod)<-rnames ### !! Atención, esto cambia la base de datos: +fechas<-colnames(clinics.mod)[grepl("DO|date", colnames(clinics.mod))] +for (i in fechas){ + clinics.mod[,i]<-as.Date(clinics.mod[,i]) +} sqlUpdate(dta, clinics.mod,"CLINICS") ## Añadir datos clínicos nuevos a la base de datos @@ -97,4 +101,10 @@ clinics.new<-upd.clinics %>% filter(OVID %in% ovid.new) %>% select(-NHC) rownames(clinics.new)<-(nsamples.clin+1):(nsamples.clin+nrow(clinics.new)) %>% as.character ### !! Atención, esto cambia la base de datos: -sqlSave(dta, clinics.new, tablename="CLINICS", append = T) +fechas<-colnames(clinics.new)[grepl("DO|date", colnames(clinics.new))] +varTypes<-rep("Date",length(fechas)) +names(varTypes)<-fechas +for (i in fechas){ + clinics.new[,i]<-as.Date(clinics.new[,i]) +} +sqlSave(dta, clinics.new, tablename="CLINICS", append = T, varTypes = varTypes)