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

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

IEA Gender and Energy Employment Data Analysis 1 - Load CSV file into R.

(IEA, Gender and Energy, IEA, Paris https://www.iea.org/data-and-statistics/data-product/gender-and-energy, Licence: CC BY 4.0)

In this post, I am going to analyze/paly around with IEA Gender and Energy Employment data. I downloaded CSV file from Gender and Energy - Data product - IEA .
The CSV file is like below.

I use R to analyze data.
I use tidyverse package.

Then, I use read_csv() function to load the CSV file into R.

I see the data frame has 22622 rows and 10 columns.
Let's use glimpse() function.

Let's use summary() function.

I see "update_at" has only one value, so I can remove it.
I will modify some variable names such as "Number of observatios" and convert character strings variables to factor type.

Let's use summary() to see how df looks like.

I see Topic has only one value, Employent, and Unit has only one value, Percent.
So, I remove the both.

Let's see numerica variables summary.

I found the data year is from 2010 to 2018. value, it is in percent is from -98 to 158, number of observations is from 11 to 1157008.

All right, I finished the first analys. Thank you!

Next post is below.

www.crosshyou.info

 


Below is R code of this post.

#
# load tidyverse package
library(tidyverse)
#
# Load the CSV file
df_raw <- read_csv("IEA_Gender_Energey_Employment.csv")
#
# glimpse
glimpse(df_raw)
#
# summary
summary(df_raw)
#
# make some changed to df_raw
df <- df_raw |> 
  select(-updated_at) |> 
  rename(sector = `Technology or Sector`,
         category = `Indicator Categories`,
         obs = `Number of observations`) |> 
  mutate(
    across(where(is.character), as.factor)
  )
#
# summary
summary(df)
#
# remove Topix and Unit.
df <- df |> 
  select(-Topic, -Unit)
#
# numeric variables summary
df |> 
  select(where(is.numeric)) |> 
  summary()
#

(The top picture is generated by Bing Image Creator, The prompt is "Foreign country secret natural paradise, close up of red peony flower, #Photo")