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?

More than 5 years have passed since last update.

R - 個人メモ

Last updated at Posted at 2019-02-03

統計ソフトRを試用開始。

たった1行で、複数列間の散布図を瞬時に描ける点に、Excelとの違いを実感。

####グラフ - 散布図

> data(iris)
> plot(iris[, 1:4])

Iris.png


####ヒートマップ

> data(iris)
> heatmap(as.matrix(iris[, 1:4]))

Heatmap.png


####確率分布
例: ガンマ分布。期間θ毎に、ランダムな事象がk回発生するまでの時間の分布。
Gamma-Eq.png

> par(ann=F)
> curve(dgamma(x, shape=1, scale=1), from=0, to=8, ylim=c(0, 1))
> par(new=T)
> curve(dgamma(x, shape=2, scale=1), from=0, to=8, ylim=c(0, 1), lty=2)
> par(new=T)
> curve(dgamma(x, shape=4, scale=1), from=0, to=8, ylim=c(0, 1), lty=3)

Gamma(a124-t1).png


####データの結合等

  • データの読み込み
> x <- read.table("~/test.txt", header=TRUE, sep="\t")
  • 列の削除
> data <- data[, c("Column1", "Column3")
  • 列名の変更
> colnames(data) <- c("A", "B", "C")
  • データの結合
> data <- merge(data1, data2, by="ColumnTest1", all=TRUE)

横(縦)に並べて結合。同じ行(列)数。

> data <- cbind(data1, data2)
> data <- rbind(data1, data2)
  • ソート
> idx <- order(data$Column, decreasing=T)
> data[idx, ]

####インストール

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?