crosshyou

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

OECD Trust in government data analysis 3 - Correlation between Trust in government and GDP, per capita GDP using R.

f:id:cross_hyou:20211120074838j:plain

Photo by Sunil Naik on Unsplash 

www.crosshyou.info

This post is following of the above post.

I have another data file like below

f:id:cross_hyou:20211120075416p:plain

This is GDP and per capita GDP data.
I will merge this data with trust in government data.

First, I load this file with read_csv() function.

f:id:cross_hyou:20211120075718p:plain

Then, I use inner_join() function to merge df and gdp_file.

df$LOCATION and gdp_file$iso are same variable, df$TIME and gdp_file$year are same variable.

f:id:cross_hyou:20211120080202p:plain

Let's change variable name LOCATION to iso and TIME to year and Value to trust because new names are more easy to understand.

f:id:cross_hyou:20211120080606p:plain

Now, let's see relationship between trust and gdp, trust and capi.

I use plot() function.

f:id:cross_hyou:20211120081939p:plain

f:id:cross_hyou:20211120082010p:plain

Since GDP has vary wide range, let's see log(GDP).

f:id:cross_hyou:20211120082529p:plain

f:id:cross_hyou:20211120082539p:plain

It seems there is no relationship.

Next, let's see Trust in government and capi: per capita GDP.

f:id:cross_hyou:20211120082840p:plain

f:id:cross_hyou:20211120082850p:plain

I see no need to convert logarithm for per capita GDP and there seems no relationship with trust and capi.
Let's see correlation with cor().

f:id:cross_hyou:20211120083219p:plain

As scatter plots showed, there are weak correlation between trust, l_gdp and capi.

That's it. Thank you!

Next post is

 

www.crosshyou.info

 



To read 1st post,

 

www.crosshyou.info