NAの扱い

*na.omit, na.exclude, na.fail, na.pass

 > x <- c(1,2,3,2,5,4,3,NA,4)
 
 > na.omit(x)
 [1] 1 2 3 2 5 4 3 4		# na.omit は NA を除く
 attr(,"na.action")
 [1] 8				# NA のあった場所
 attr(,"class")
 [1] "omit"			# クラスは "omit"
 
 > na.exclude(x)
 [1] 1 2 3 2 5 4 3 4		# na.excule は NA を除く
 attr(,"na.action")
 [1] 8				# NA のあった場所
 attr(,"class")
 [1] "exclude"			# クラスは "exclude"
 
 > na.fail(x)			# na.fail は NA があるとエラーにする
 以下にエラーna.fail.default(x) : オブジェクト中に欠損値があります
 
 > na.pass(x)
 [1]  1  2  3  2  5  4  3 NA  4	# na.pass は NA を素通しする


-関連ページ

[[NA,NaN,NULL,Inf:http://www.okada.jp.org/RWiki/index.php?NA%2CNaN%2CNULL%2CInf]]


トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS