Skip to Content
Rグラフィックスクックブック 第2版 ―ggplot2によるグラフ作成のレシピ集
book

Rグラフィックスクックブック 第2版 ―ggplot2によるグラフ作成のレシピ集

by Winston Chang, 石井 弓美子, 河内 崇, 瀬戸山 雅人
November 2019
Intermediate to advanced
472 pages
9h 23m
Japanese
O'Reilly Japan, Inc.
Content preview from Rグラフィックスクックブック 第2版 ―ggplot2によるグラフ作成のレシピ集
83
5
散布図
散布図は、
2
つの連続値変数の関係を表示するのに使われます。散布図では、データセットの各観測
点は、点で表現されます。散布図には、何らかの統計モデルに基づいた予測値を示す線も一緒に表示
されていることがよくあります。これは、
R
ggplot2
パッケージを使うと簡単に行うことができ、点を
ただ見ただけではすぐに傾向がわからないデータから意味を見出しやすくなります。
データセットが大きい場合、各観測点をすべてプロットすると点が重なり、互いに覆い隠してしまう
状態になってしまいます。この問題に対処するために、データを表示する前に要約したい場合もある
でしょう。この章ではこの要約の方法も見ていくことにします。
レシピ
5.1
 基本的な散布図を作成する
問題
2
つの連続値変数を使って散布図を作成したい。
解決策
geom_point()
を使い、ある変数を
x
、別の変数を
y
にマッピングします。
ここでは
heightweight
データセットを使います。このデータセットには多くの列がありますが、こ
の例では
2
つの列だけを使います(図5-1)。
library(gcookbook) # heightweight
データセットを使うために
gcookbook
を読み込む
library(dplyr)
#
使用する
2
つの列の概要を表示
heightweight %>%
select(ageYear, heightIn)
#> ageYear heightIn
84
5
章 散布図
#> 1 11.92 56.3
#> 2 12.92 62.3 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

詳説 イーサネット 第2版

詳説 イーサネット 第2版

Charles E. Spurgeon, Joann Zimmerman, 三浦 史光, 豊沢 聡
行動を変えるデザイン ―心理学と行動経済学をプロダクトデザインに活用する

行動を変えるデザイン ―心理学と行動経済学をプロダクトデザインに活用する

Stephen Wendel, 武山 政直, 相島 雅樹, 反中 望, 松村 草也
リーンエンタープライズ ―イノベーションを実現する創発的な組織づくり

リーンエンタープライズ ―イノベーションを実現する創発的な組織づくり

Jez Humble, Joanne Molesky, Barry O'Reilly, 角 征典, 笹井 崇司, Eric Ries

Publisher Resources

ISBN: 9784873118925Other