1
1

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-05-15

#データを正規化する関数を作成

###標準化とは
与えられたデータを平均が0で分散が1のデータに変換する操作のこと
各データ xi から平均 μ を引き,その値を標準偏差 σ で割ることで達成される       
zi=(xi-μ)/σ

###与えられたdata(行列)を列ごとにを標準化する関数  standalizeを作成

standalize <- function(data,ncol(data))
{ for(i in ncol(data))
  {
  x <- as.matrix(data[,i])
  y <- (x-mean(x)/sd(x))
  data[,i] <- y
 }
  return(data)
}

この関数はfor文を解除すると、指定列だけを標準化できます。

1
1
1

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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?