4
I’m doing a job using the transparency portal, I need to join two databases prof1.csv and prof2.csv. The final result of merge, that I named prof.csv, is doubling rows due to columns 18 of gross salary and 19 of net salary. I would like the result equal to Prof.csv.. That is, I do not want to duplicate lines even if wages are different and I want to keep the wage values of different months in line. Follow a small part of the code I’m using.
url1 <- url("https://raw.githack.com/fsbmat/salarioDocente/master/prof1.csv")
url2 <- url("https://raw.githack.com/fsbmat/salarioDocente/master/prof2.csv")
prof1 <- read.csv2(url1, header = TRUE,encoding = "ASCII")
prof2 <- read.csv2(url2, header = TRUE,encoding = "ASCII")
Prof <- merge(prof1,prof2,by=c("ID_SERVIDOR_PORTAL" ,"NOME" ,"CPF" ,
"DATA_INICIO_AFASTAMENTO" ,"DATA_TERMINO_AFASTAMENTO",
"JORNADA_DE_TRABALHO" ,"DATA_INGRESSO_ORGAO" ,"UF_EXERCICIO" ,
"Nivel" ,"LOTACAO" ,"REG_JURIDICO" ,"VINCULO" ,
"CARGO" ,"Org_Exercicio" ,"Tempo")
,all.x= T, all.y= T)
Hi Rafael, I had not noticed this. It has to keep the columns
NívelandCARGOwith the spreadsheet values prof2.csv using the functionmerge? In that case,Nível.yandCARGO.yare the answers that interest me!– fsbmat
The variables with end
.xare ofprof1and the final.yare that ofprof2.– Rafael Cunha
Yes, I understand that, but the spreadsheets I work with are huge, so I want to know the simplest way to always keep the values of prof2. With new codes I can do this, for example: Prof$Nivel <- Prof$Nivel. y Prof$Cargo <- Prof$CARGO. y Prof <- Prof %>% select(1:13,16:21,24:25), but if it were possible to keep this information already in the first code it would be better!
– fsbmat
I added two lines of code, see if it fits what you want
– Rafael Cunha