科学の箱

科学・IT・登山の話題

R

Rで型が不明なときの対処方法

投稿日:

データセットならstrを使う

> str(iris)
'data.frame':   150 obs. of  5 variables:
 $ Sepal.Length: num  5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9 ...
 $ Sepal.Width : num  3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1 ...
 $ Petal.Length: num  1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5 ...
 $ Petal.Width : num  0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1 ...
 $ Species     : Factor w/ 3 levels "setosa","versicolor",..: 1 1 1 1 1 1 1 1 1 1 ..

特定の変数ならばmodeを使う

> x <- rnorm(1000)
> mode(x)
[1] "numeric"

ちなみにlistをベクタにするためにはunlistを使う

> x <- unlist(iris[1])
> mode(x)
[1] "numeric"

メタ情報

inarticle



メタ情報

inarticle



-R
-

執筆者:


comment

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

関連記事

no image

dataanalysis-002-week3

exploratory analysis グラフの目的 データのおおよそを理解する パターンを探す モデリングを探す デバッグ コミュニケーション boxplot 値のレンジを確認する 他の値とレンジ …

no image

検定力分析(パワーアナリシス)

研究に必要な精度に対するサンプル数を求めるための分析方法 下記が詳しい http://miuse.mie-u.ac.jp/bitstream/10076/11867/1/10C15625.pdf ht …

no image

Rでのランダムデータ作成 – 上級編

平均が異なるランダムデータを作成する > x <- rnorm(12, mean=rep(1:3,each=4), sd=0.2) > y <- rnorm(12, mean= …

no image

oneway.test, aov, anovaの違い-2

さてoneway.test, aov, anovaの違いをもとにしてそれぞれの関数について調べてみる。 機能 advantage disadvantage oneway.test 分散分析 等分散を仮 …

no image

一対比較法によるリーグ戦の分析

一対比較法を利用すると2者の比較から全体の重要度や実力を数字で表現できる。 一対比較法を使った分析の手順は以下のようにすすめる。 データを取得する。 一対比較法のデータは複数の項目から2者を選び比較し …

2014年1月
« 12月   2月 »
 12345
6789101112
13141516171819
20212223242526
2728293031  

side bar top



アーカイブ

カテゴリー