Rで何かをしたり、読書をするブログ

政府統計の総合窓口のデータや、OECDやUCIやのデータを使って、Rの練習をしています。ときどき、読書記録も載せています。

OECD Road accidents data analysis 3 - make a histogram with ggplot() + geom_histogram(). Log conversion makes better looking histogram.

f:id:cross_hyou:20210801084916j:plain

 Photo by Robert Lukeman on Unsplash  

www.crosshyou.info

 This post is following og above post.

We have five combinations for value,

1. ACCI & NBR

2. DEATH & HAB

3. DEATH & VEH

4. DEATH & NBR

5. INJURE & NBR

So, I will make five sub data frames.

f:id:cross_hyou:20210801085418p:plain

f:id:cross_hyou:20210801085511p:plain

f:id:cross_hyou:20210801085552p:plain

f:id:cross_hyou:20210801085632p:plain

f:id:cross_hyou:20210801085722p:plain

Then, let's merge those five data frames.

f:id:cross_hyou:20210801085826p:plain

I used inner_join() function and common colums are iso and time. So, I add by = c("iso", "time").

Summary is below.

f:id:cross_hyou:20210801090039p:plain

We see time starts from 1994 and ends in 2019. It is 26 years.

Let's see each variables histogram.

f:id:cross_hyou:20210801090742p:plain

f:id:cross_hyou:20210801090754p:plain

We see 2017 has the most observations.

f:id:cross_hyou:20210801091028p:plain

f:id:cross_hyou:20210801091046p:plain

For acci_nbr, it is better to convert log value.

f:id:cross_hyou:20210801091340p:plain

f:id:cross_hyou:20210801091351p:plain

Let's see death_hab.

f:id:cross_hyou:20210801091538p:plain

f:id:cross_hyou:20210801091552p:plain

It maybe better to convert log value.

f:id:cross_hyou:20210801092928p:plain

f:id:cross_hyou:20210801092942p:plain

Let's see death_veh

f:id:cross_hyou:20210801091800p:plain

f:id:cross_hyou:20210801091811p:plain

It maybe better to convert log value.

f:id:cross_hyou:20210801093113p:plain

f:id:cross_hyou:20210801093125p:plain

Let's see death_nbr

f:id:cross_hyou:20210801092329p:plain

f:id:cross_hyou:20210801092344p:plain

It is better to convert log value.

f:id:cross_hyou:20210801092606p:plain

f:id:cross_hyou:20210801092618p:plain

Let's see injure_nbr

f:id:cross_hyou:20210801093410p:plain

f:id:cross_hyou:20210801093421p:plain

It is better to convert log

f:id:cross_hyou:20210801093628p:plain

f:id:cross_hyou:20210801093641p:plain

We see each variables histogram and found that it is better to convert log value.

That's it. Thank you!

The next post is

 

www.crosshyou.info

 

 

To see the 1st post,

 

www.crosshyou.info