Stata与R:功能对比、自动化设置及模拟示例
1. R与Stata功能概述
R拥有超过3000个附加包,许多包包含多个程序,几乎能完成Stata的所有任务,甚至更多。以下程序可用于统计R当前可用的包数量:
> setRepositories()
(select all of the repositories it offers)
> myPackageNames <- available.packages()
> length(unique( rownames(myPackageNames) ))
[1] 3175
在发布时,有3175个附加包。更多关于R包的详细信息可在以下网站获取:
- 按任务组织的信息:http://cran.r-project.org/web/views/index.html
- 按任务搜索的网站:http://biostat.mc.vanderbilt.edu/s/finder/finder.html
- 大多数R包的详细信息:http://www.r-project.org/ ,选择CRAN,然后选择镜像,再选择Packages。
1.1 Stata命令与R函数对比
以下是Stata命令和函数与R函数的部分对比:
| Stata命令或函数 | R函数(或包名) |
| — | — |
| * comment | # comment |
| append | rbind.fill (reshape); rbind |
| anova; o