Why not login to Qiita and try out its useful features?

We'll deliver articles that match you.

You can read useful information later.

1
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?

RAdvent Calendar 2024

Day 5

Rを学びたい Step4(棒グラフ)

Posted at

はじめに

Rを学びたいStep4です!今回は棒グラフを作成します

ソースコード

bar_plot.R
# PNGデバイスを開く
png("bar_plot.png")

# 行列の作成
mat <- matrix(c(12, 2, 5, 8, 7, 10, 3, 6, 9, 4, 11, 1, 4, 7, 6, 9, 2, 5, 8, 3), nrow = 10, ncol = 2)

# 行列の内容を表示
print("行列の内容:")
print(mat)

# 各列の合計を計算
col_sums <- colSums(mat)

par(family = "HiraginoSans-W3")

# 棒グラフの作成
barplot(col_sums, names.arg = c("Column 1", "Column 2"), col = "blue", main = "棒グラフ", ylab = "合計値")

# PNGデバイスを閉じる
dev.off()

image.png

1
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
1
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?