书签 分享
• /  114
• 下载费用： 19.90积分

# Verzani-SimpleR simpleR – Using R for Introductory Statistics John Verzani 20000400006000080000120000160000 2e+054e+056e+058e+05 y page i Preface These notes are an introduction to using the statistical software package R for an introductory statistics course. They are meant to accompany an introductory statistics book such as Kitchens “Exploring Statistics”. The goals are not to show all the features of R, or to replace a standard textbook, but rather to be used with a textbook to illustrate the features of R that can be learned in a one-semester, introductory statistics course. These notes were written to take advantage of R version 1.5.0 or later. For pedagogical reasons the equals sign, =, is used as an assignment operator and not the traditional arrow combination The is called the prompt. In what follows below it is not typed, but is used to indicate where you are to type if you follow the examples. If a command is too long to fi t on a line, a + is used for the continuation prompt. Entering data with c The most useful R command for quickly entering in small data sets is the c function. This function combines, or concatenates terms together. As an example, suppose we have the following count of the number of typos per page of these notes: 2 3 0 3 1 0 0 1 To enter this into an R session we do so with typos = c(2,3,0,3,1,0,0,1) typos  2 3 0 3 1 0 0 1 Notice a few things ? We assigned the values to a variable called typos ? The assignment operator is a =. This is valid as of R version 1.4.0. Previously it was (and still can be) a mean(typos)  1.25 As well, we could call the median, or var to fi nd the median or sample variance. The syntax is the same – the function name followed by parentheses to contain the argument(s): median(typos)  1 var(typos)  1.642857 Data is a vector The data is stored in R as a vector. This means simply that it keeps track of the order that the data is entered in. In particular there is a fi rst element, a second element up to a last element. This is a good thing for several reasons: ? Our simple data vector typos has a natural order – page 1, page 2 etc. We wouldn’t want to mix these up. ? We would like to be able to make changes to the data item by item instead of having to enter in the entire data set again. ? Vectors are also a mathematical object. There are natural extensions of mathematical concepts such as addition and multiplication that make it easy to work with data when they are vectors. Let’s see how these apply to our typos example. First, suppose these are the typos for the fi rst draft of section 1 of these notes. We might want to keep track of our various drafts as the typos change. This could be done by the following: typos.draft1 = c(2,3,0,3,1,0,0,1) typos.draft2 = c(0,3,0,3,1,0,0,1) That is, the two typos on the fi rst page were fi xed. Notice the two diff erent variable names. Unlike many other languages, the period is only used as punctuation. You can’t use an _ (underscore) to punctuate names as you m

Verzani SimpleR 天天文库所有资源均是用户自行上传分享，仅供网友学习交流，未经上传用户书面授权，请勿作他用。

## 当前资源信息 新起点 • ## 高中一年级生物质壁分离.ppt

• 本站为“文档C2C交易模式”，即用户上传的文档直接卖给(下载)用户，本站只是中间服务平台，本站所有文档下载所得的收益归上传人(含作者)所有【成交的100%(原创)】。本站是网络服务平台方，若您的权利被侵害，侵权客服QQ：1290478887 欢迎举报。

1290478887@qq.com 2017-2027 https://www.wenku365.com 网站版权所有

收起
展开