This post is solutions of chapter 1 of `A Handbook of Statistical Analyses Using R, Second Edition'. As far as I know, there's no solutions on Web, so I decided to post my answers and hope to sophiscate them through discussing if needed.
このポストはRによる統計解析ハンドブック(第2版)の第1章の解答になります。私の知る限り、解法はWeb上にありませんので、私の解答を掲載することを決心しました。必要があれば議論して解答をより良くしたいと思っています。
Because almost no contents in the text book is written in this post, so please get one previously.
テキストに書かれている内容はほぼこのポストにありませんので、本は予め入手しておいてください。
1
library(HSAUR2) prof.meds <- tapply(Forbes2000$profits, Forbes2000$country, median, na.rm=T) print(prof.meds[c("United States", "United Kingdom", "France", "Germany")])
In the following answers, assume that `library(HSAUR2)' is already executed.
以後library(HSAUR2)は既に実行されていることを仮定せよ。
2
ger.deficit <- Forbes2000$country == "Germany" & Forbes2000$profits < 0 print(Forbes2000[ger.deficit, ])
3
Insurance Company is majority of this data (bermuda).
bermuda <- Forbes2000$country == "Bermuda" print(table(Forbes2000[bermuda, "category"]))
4
big.profit <- Forbes2000[Forbes2000$profits >= sort(Forbes2000$profits, dec=T)[50],] big.profit <- big.profit[!is.na(big.profit$profits),] plot(big.profit$assets, big.profit$sales, log="xy", type="n") text(big.profit$assets, big.profit$sales, abbreviate(big.profit$country))
5
print(tapply(Forbes2000$profits, Forbes2000$country, mean, na.rm=T)) larger <- function(x, th){ return(length(which(x > th))) } print(tapply(Forbes2000$profits, Forbes2000$country, larger, 5))
0 件のコメント:
コメントを投稿