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

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

IEA Gender and Energy Employment Data Analysis 3 - Making graphs to explore data analysis

www.crosshyou.info

This post is continueation of above post.

In this post, let's examine gender gap data by year, by sector and so on.

Before makinga graphs, I renamed "value" to "gap".

Let's start with Year.

We see there is not large differences by Year.

 

Next, let's see by sector.

We see there is not much difference in terms of the median, but there are noticeable differences in the distribution.

Next, let's check Indicator.

There are differences in both the median and the distribution.

 

Next, let's look at category.

There are no large differences in either the median or the distribution.

Next, let's see Country.

Canada has the smallest gap, and Romania has the largest.

That's it.

Next post is

 

www.crosshyou.info

 


To read from the first post of this series,

www.crosshyou.info

Below it the R code for this post.
#
# Value is Gender Gap. So rename
df <- df |> 
  rename(gap = Value)
df
#
# Gap by Year
df |> 
  group_by(Year) |> 
  summarize(
    min = min(gap),
    median = median(gap),
    mean = mean(gap),
    max = max(gap),
    n = n()
  )
#
# graph of mean by year
df |> 
  ggplot(aes(x = Year, y = gap)) +
  geom_boxplot(aes(group = Year)) +
  theme_minimal()
#
# Gap by sector
df |> 
  group_by(sector) |> 
  summarize(
    min = min(gap),
    median = median(gap),
    mean = mean(gap),
    max = max(gap),
    n = n()
  )
#
# graph of mean by sector
df |> 
  mutate(sector = reorder(sector, gap, median)) |> 
  ggplot(aes(x = sector, y = gap)) +
  geom_boxplot(aes(group = sector)) +
  theme_minimal()
#
# Gap by Indicator
df |> 
  group_by(Indicator) |> 
  summarize(
    min = min(gap),
    median = median(gap),
    mean = mean(gap),
    max = max(gap),
    n = n()
  )
#
# graph of mean by Indicator
df |> 
  mutate(Indicator = reorder(Indicator, gap, median)) |>
  ggplot(aes(x = Indicator, y = gap)) +
  geom_boxplot(aes(group = Indicator)) +
  theme_minimal()
#
# Gap by category
df |> 
  group_by(category) |> 
  summarize(
    min = min(gap),
    median = median(gap),
    mean = mean(gap),
    max = max(gap),
    n = n()
  )
#
# graph of mean by category
df |>
  mutate(category = reorder(category, gap, median)) |>
  ggplot(aes(x = category, y = gap)) +
  geom_boxplot(aes(group = category)) +
  theme_minimal()
#
# gap by Country
df |> 
  group_by(Country) |> 
  summarize(
    min = min(gap),
    median = median(gap),
    mean = mean(gap),
    max = max(gap),
    n = n()
  )
#
# graph of mean by Country
df |>
  mutate(Country = reorder(Country, gap, median)) |>
  ggplot(aes(x = Country, y = gap)) +
  geom_boxplot(aes(group = Country)) +
  theme_minimal()
#

 

(Top picture is generated by Bing Image Creator. Prompt is Beautiful natural landscape, blue sky, white cloud, green grass, close up of a purple Ceanothus flower, photo)