Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicated e anti_join #14

Open
temospena opened this issue Feb 12, 2020 · 1 comment
Open

duplicated e anti_join #14

temospena opened this issue Feb 12, 2020 · 1 comment

Comments

@temospena
Copy link
Owner

temospena commented Feb 12, 2020

table(duplicated(OTHER$ID1)) # verifica se há repetidos

#separa os repetidos dos que são únicos
cuidado com fazer apenas uma ordem! pq em 1123 > F,T,F,F e em fromLast=T > T,F,F,F

table(duplicated(HACKfamilias$ID1)) #4509 em 29121 (15,4%)
HACKfamilias$duplic <- duplicated(HACKfamilias$ID1)
HACKfamilias$duplic2 <- duplicated(HACKfamilias$ID1, fromLast = T)
HACKfamilias$duplic3 <- duplicated(HACKfamilias$ID2)
HACKfamilias$duplic4 <- duplicated(HACKfamilias$ID2, fromLast = T)
table(HACKfamilias$duplic==F & HACKfamilias$duplic2==F & HACKfamilias$duplic3==F & HACKfamilias$duplic4==F) #21655 limpinhos
CORRECTid <- HACKfamilias[HACKfamilias$duplic==F & HACKfamilias$duplic2==F & HACKfamilias$duplic3==F & HACKfamilias$duplic4==F,c(1,2,3)] #temos 21655 correctos, faltam 2963 ?
ERRADOS <- anti_join(HACKfamilias[,c(1,2,3)],CORRECTid) #são 7466 que têm de ser reduzidos a 2963 ?
@temospena
Copy link
Owner Author

e ainda arrange, e %in%

CORRECT <- arrange(rbind(CORRECT,CORRECTindivifixe),ID1) #ficamos com 23557, ainda faltam 1061
#4,3%
table(ERRADOS$ID1%in%CORRECT$ID1)
ERRADOS <- ERRADOS[!(ERRADOS$ID1%in%CORRECT$ID1),]
ERRADOS <- ERRADOS[!(ERRADOS$ID2%in%CORRECT$ID2),] #são 2495 que têm de ser reduzidos a 1061
ERRADOS <- arrange(ERRADOS, ID1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant