前回の記事では、hist() を使って描いたヒストグラムに、各階級の度数を書き入れました。
ただ、毎回スクリプトを書いているのは面倒なので(?)、上記機能を組み入れたりして hist() を拡張した myhist() を作りました。
基本的には自分用なので、平均点を表す線を引いたりするのも入れてあります。もしもお役に立ちそうでしたらご自由にお使いください。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
myhist <- function(d){ | |
info <- hist(x=d | |
####高水準作図関数#### | |
#,breaks= #階級の区切り | |
#,main= #ヒストグラムのタイトル | |
#,xlim= #x軸 | |
#,ylim= #y軸 | |
#,xlab= #x軸のタイトル | |
#,ylab= #y軸のタイトル | |
) | |
####低水準作図関数#### | |
text(x=info$mids, y=1, info$counts) #度数をヒストグラム下部に記入 | |
#text(x=info$mids, y=info$counts-1, info$counts) #度数をヒストグラム上部に記入 | |
#text(x=info$mids, y=info$counts/2, info$counts) #度数をヒストグラム真ん中に記入 | |
#abline(v=mean(d)) #平均を表す実線を引く | |
#text(x=mean(d), y=max(info$counts)/2, signif(mean(d), 2)) #平均 (小数点1桁) を記入 | |
} |
0 件のコメント:
コメントを投稿