STATISTICS AN INTRODUCTION USING R统计学介绍使用.pdfVIP

  • 98
  • 0
  • 约5.49万字
  • 约 30页
  • 2018-03-05 发布于四川
  • 举报

STATISTICS AN INTRODUCTION USING R统计学介绍使用.pdf

STATISTICS AN INTRODUCTION USING R统计学介绍使用.pdf

STATISTICS: AN INTRODUCTION USING R By M.J. Crawley Exercises 2. VECTORS AND LOGICAL ARITHMETIC The screen prompt is an excellent calculator. All of the usual calculations can be done directly, and the standard order of precedence applies: powers and roots first, then multiplication and division, then finally addition and subtraction. Although there is a named function for square roots, sqrt, roots are generally calculated as fractional powers. So the cube root of 8 is 8^(1/3) [1] 2 Use brackets as necessary to over-ride the precedence. For a t-test, where the value y A −y B required is and the numbers are 5.7, 6.8 and 0.38 you type SE d abs(5.7-6.8)/0.38 [1] 2.894737 All the mathematical functions you could ever want are here (see Table 1). Integer quotients and remainders are obtained using the rather clumsy notation %/% (percent, divide, percent) and %% (percent, percent) respectively. Suppose we want to know the integer part of a division: say, how many 13’s are there in 119 119 %/% 13 [1] 9 Now suppose we wanted to know the remainder (what is left over when 119 is divided by 13): in maths this is known as modulo 119 %% 13 [1] 2 Various sorts of rounding (rounding up, rounding down, rounding to the nearest integer) can be done easily. Take 5.7 as an example. The ‘greatest integer’ function is floor floor(5.7) [1] 5 and the ‘next integer’ function is ceiling ceiling(5.7) [1] 6 You can round to the nearest integer by adding 0.5 to the number then using floor. There is a built in function for this, but we can easily write one of our own to introduce the notion of function-writing. Call it rounded, then define it as a function like this rounded-function(x) floor(x+0.5) Now we can use the new function rounded(5.7) [1] 6 Table 1. Mathemati

您可能关注的文档

文档评论(0)

1亿VIP精品文档

相关文档