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 5 years have passed since last update.

Rで棒グラフが出力できないアナタへ ---初心者向け---

Last updated at Posted at 2020-02-07
tags: rBasicLearning

棒グラフ

棒グラフを使う場合

棒グラフは, 質的データの概観を見る時に使う.

使用するデータ

今回は, データとしてmtcarsを使う.

library(datasets)
mtcars

棒グラフが働かない場合

以下のように, 生データを入れただけだと, グループ化されていないため, 一つ一つのデータの羅列になってしまう.

barplot(mtcars$cyl)             # Doesn't work

データを分割表にして, 棒グラフにする

生データではなく, 分割表にすることで, データをまとめ, 棒グラフにする.

# Need a table with frequencies for each category
cylinders <- table(mtcars$cyl)  # Create table
barplot(cylinders)              # Bar chart

plot()とhist()の違い

plot()とhist()は以下のような, 違いがある.

plot(cylinders)                 # Default X-Y plot (lines)
hist(cylinders)                 # histgram


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?