R 练习题 for 统计 09
Exercise 1
Calculate the first 50 powers of 2, 2*2, 2*2*2, etc.
Calculate the squares of the integer numbers from 1 to 50.
Which pairs are equal, i.e. which integer numbers fulfill the condition
How many pairs are there?(Use R to solve all these questions!)
2n
2
n
.
Exercise 2
Calculate the sine, cosine, and the tangent for numbers ranging from 0 to 2*
(with distance 0.1 between them).
Remember that tan(x)=sin(x)/cos(x). Now calculate the difference between tan(x)
and sin(x)/cos(x) for the values above. Which values are exactly equal? What is the
maximum difference? What is the cause of the differences?
Exercise 3
Use the R help routines (not the manuals) to find out how to use the functions floor,
trunc, round, ceiling, and what they do. Predict what each of these functions will
give as an answer for the numbers -3.7 and +3.8. Use R to test your predictions.