Exclude line from a dataset not contained in another [R]

Asked

Viewed 21 times

1

Hello, I am doing a work on HDI and Covid and I need to join two columns, the problem is that both are with number of different lines, and the reason is the number of municipalities in which each has, one more updated with less and the other older with more.

In both, I have the municipality code and I believe that with this I can exclude from the IDH dataset the lines of municipalities that the code is not in the Covid dataset.

But it’s not working, someone imagines how to do?

The columns of the HDI dataset: name, idhm_r, code

The COVID dataset columns: name, code, cases, Deaths

Both are already ordered by code.

Thank you very much!

  • In IDH is nome with o and in Covid name with a? Anyway, i<-which(IDH$code %in% Covid$code) followed by IDH2 <- IDH[i,] selects HDI lines with codes in Covid.

  • Take a look at the documentation of ?dplyr::anti_join(). Should help you.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.