crosshyou

主にクロス表(分割表)分析をしようかなと思いはじめましたが、あまりクロス表の分析はできず。R言語の練習ブログになっています。

OECD Doctors' consultations data analysis 2 - use inner_join() to merge two data frames

 

f:id:cross_hyou:20210605163555j:plain

Photo by Sergey Shmidt on Unsplash

 

www.crosshyou.info

 This post is following of above post.
In the previous post, I read OECD Doctors' consultation data in R. But we don't know what LOCATION is what country. So I will add those information.

First, I load ISO country data from 

https://raw.githubusercontent.com/lukes/ISO-3166-Countries-with-Regional-Codes/master/all/all.csv

f:id:cross_hyou:20210605164032p:plain

f:id:cross_hyou:20210605164050p:plain

We only need name(which is contry name), alpha-3(which is equivalnet to LOCATION of df), region and sub-region. So, I use select() function to selct only them.

f:id:cross_hyou:20210605164254p:plain

I change alpha-3 to LOCATION and sub-region to sub_region.

f:id:cross_hyou:20210605164430p:plain

Using inner_join(), I merge df and name_code

f:id:cross_hyou:20210605164617p:plain

And I changed region and sub_region to factor from character.

f:id:cross_hyou:20210605164730p:plain

All right, now I have good data frame:df to analyze.

That's it. Thank you!

 

Next post is

 

www.crosshyou.info

 

 

To read the 1st post,

 

www.crosshyou.info