#Gestionando bases de datos

install.packages(“readxl”) library(readxl) #paquete para importar archivos en Excel

data1 <- read_excel(“ejemplo1(1).xls”, sheet = “Hoja1”) #comando del readxl data2 <- read_excel(“ejemplo1(1).xls”, sheet = “Hoja2”) data3 <- read_excel(“ejemplo1(1).xls”, sheet = “Hoja3”) data4 <- read_excel(“ejemplo1(1).xls”, sheet = “Hoja4”)

total1 <- merge(data1,data2,by=“num”, all=TRUE) total1 total2 <- merge(data3,data4,by=“num”, all=TRUE) total2

total <- rbind(total1, total2) total

x=read_excel(“ejemplo2(1).xls”,sheet=“repetidos”)

xdup=x[duplicated(x), ] #encontrando duplicados str(xdup)

xsindup=unique(x) #guardando sin duplicados str(xsindup)

z=read_excel(“ejemplo3(1).xls”)

zAdup=z[duplicated(z$A,fromLast=TRUE), ] str(zAdup) zAsindup=z[!duplicated(z$A,fromLast=TRUE),] str(zAsindup)

install.packages(“writexl”) library(writexl)

write_xlsx(zAsindup,“zAsindup.xlsx”) L=read_excel(“zAsindup.xlsx”, sheet = “Sheet1”)

save(L,file=“L.RData”)