Wsyang.com

Mac, Statistics, and Common Life in Japan

[R] 결손치를 히스토그램에 나타내는 방법

leave a comment

기본적인 R의 histgram에서는 결손치를 그래프에 표시하지 않습니다. 결손치의 수를 그래프에 나타내기 위해서는 약간의 과정이 필요합니다.

1
2
3
4
5
> sample.data < - as.factor(sample(c(1,0,NA),100,replace=T))
> sample.data < - as.character(sample.data)
> sample.data[is.na(sample.data)] < - " NA"
> sample.data < - factor(sample.data)
> plot(sample.data)

rplot3

“ggplot2″ 패키지를 이용하면 좀더 멋진 그래프를 얻을 수 있습니다.

1
2
> ibrary(ggplot2)
> qplot(sample.data, geom="histogram")

rplot21

 

 

Written by 양 우성

2008/07/07 at 12:04 pm

Posted in R-Tips

Tagged with