readxl (1)

Rでのデータインポート入門

Filip Schouwenaars

Instructor, DataCamp

Microsoft Excel

  • 一般的なデータ分析ツール
  • Excel と連携する R パッケージが多数
  • readxl - Hadley Wickham 作
Rでのデータインポート入門

Excel データの典型構造

  • 表形式データの複数シート

Screen Shot 2019-07-15 at 3.27.34 PM.png

Rでのデータインポート入門

readxl

  • excel_sheets()
    • シート一覧を取得
  • read_excel()
    • データを R に読み込む
install.packages("readxl")
library(readxl)
Rでのデータインポート入門

excel_sheets()

dir()
"cities.xlsx"  "the_rest_is_secret.txt"
excel_sheets("cities.xlsx")
"year_1990" "year_2000"
Rでのデータインポート入門

read_excel()

read_excel("cities.xlsx")
# A tibble: 4 × 2
    Capital Population
      <chr>      <dbl>
1  New York   16044000
2    Berlin    3433695
3    Madrid    3010492
4 Stockholm    1683713
read_excel("cities.xlsx", sheet = 2)
read_excel("cities.xlsx", sheet = "year_2000")
# A tibble: 4 × 2
    Capital Population
      <chr>      <dbl>
1  New York   17800000
2    Berlin    3382169
3    Madrid    2938723
4 Stockholm    1942362
Rでのデータインポート入門

Passons à la pratique !

Rでのデータインポート入門

Preparing Video For Download...