0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

エクセル縛りで整然データからグラフを書く方法:「ピボットテーブルで集計」機能でデータを整形する

Last updated at Posted at 2020-12-08

tidy dataであるtest.csvから、timeをx軸、valueをy軸にとる折れ線グラフをRやpythonを使わずに作りたい。
想定場面:Rやpythonを使えない学生が、googleフォームで集計した実験データの整理・グラフ描画をする際の指導

test.csv
image.png

手順

  1. csvファイルをエクセル形式で保存する
  2. エクセルの「メニューバーからデータ」->「ピポットテーブルで集計」、範囲を選択してOK
  3. ピポットテーブルのフィールド(カーソルを合わせると出てくる)において、"列"にx軸としたいtime、"行"やフィルターに分類表記したい属性、"値"にy軸としたいvalueをドラッグアンドドロップで設定する。
  4. ピポットテーブルから直接範囲選択してグラフを書こうとすると怒られる(!!?)ので、グラフは一度コピーしてから作成する。

一連の操作の画面キャプチャ↓

ezgif.com-video-to-gif-3.gif

これならExcelに苦手意識を持っている学生でも出来るはず。
また、GoogleSpreadSheetでもほぼ同様の操作でグラフ作成が可能である。

なおRでは、

df <- read.csv("test.csv")
g <- ggplot(df, aes(x=time, y=value, color=id)) + geom_point() + geom_line() + facet_wrap(.~class) + theme_bw()
g
プロット結果 ![test.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/549192/51c57748-aaae-d49f-5d74-34761f75717c.png)

などとすればよい。データ行がどんなに長くても基本これでOK、簡単!

[21/12/21 追記]Microsoftのサポートに動画付きの情報がありました.
https://support.microsoft.com/en-us/office/create-a-pivotchart-c1b1e057-6990-4c38-b52b-8255538e7b1c#OfficeVersion=Windows

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?