- 98
- 0
- 约5.49万字
- 约 30页
- 2018-03-05 发布于四川
- 举报
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
您可能关注的文档
- SIZE FECUNDITY RELATIONSHIPS AND REPRODUCTIVE INVESTMENT IN…关系和生殖投资在.pdf
- SKEW PRODUCTS WITH SIMPLE APPROXIMATIONS具有简单近似的跳跃产品.pdf
- Skitse til en bestemmelse af overgan gen fra II til III….pdf
- Social Resilience in African Dryland Livelihoods Deriving…非洲干旱地区生计的社会复原能力.pdf
- SOCIOLINGUISTICA E NELLA DIDATTICA DELL’ITALIANO A STRANIERI….pdf
- Sofie Damen Dimitri Mortelmans Lana Raeymaeckers Roliene….pdf
- Software Tool to Predict The Wind Energy Production Losses Due…预测风能生产损失的软件工具.pdf
- Soil arthropods beneficially rather than detrimentally impact…土壤节肢动物有益而不是有害的影响.pdf
- Solitary wave interactions in dispersive equations using…使用的色散方程中的孤波相互作用.pdf
- Solitons in dissipative media National Institute of…孤子在耗散媒体国家研究所.pdf
原创力文档

文档评论(0)