From 8b9b9b9681f361605eb93da1c8b1706312aede44 Mon Sep 17 00:00:00 2001 From: Marin Jimenez <44653479Z@ICO.SCS.local> Date: Mon, 25 Oct 2021 17:21:21 +0200 Subject: [PATCH] =?UTF-8?q?Correcci=C3=B3n=20update=20y=20definir=20fechas?= =?UTF-8?q?.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- RellenarOVBD.R | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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)