• Keine Ergebnisse gefunden

Exercise Series 1

N/A
N/A
Protected

Academic year: 2021

Aktie "Exercise Series 1"

Copied!
2
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Using R for Statistical Data Analysis and Graphics Fall 2009

Exercise Series 1

1. Start R. The login for the computers is your n-ethz login. If you do not have one, ask the assistent.

Find the entry Tinn-R in the Start menu. Then find the entry ’Start preferred Rgui’

from Tinn-R’s menu ’R’. You now have

• a window in which R runs. It shows the prompt symbol > on the last line. You can enter S commands here directly.

• a window in which you can enter commands and then send them to the R process by pushing one of the buttons. This has the advantage that you can easily change any command and then send it again – just in case you should ever make a mistake... or if you want to try several variations of a command.

Now type the following lengthy two lines into the editor window and send it to make the dataset d.sportavailable for the following exercises.

d.sport <- read.table("http://stat.ethz.ch/Teaching/Datasets/WBL/sport.dat", header=TRUE)

Once you just get the next prompt (>), then type d.sport

into the R window to see the result.

2. Use the following commands to repeat the demonstration of the introductory lecture.

d.sport[,"kugel"]

hist(d.sport[,"kugel"])

hist(d.sport[,"kugel"], nclass=10)

hist(d.sport[,"kugel"],,,,,,,,,,,,,,,,10) plot(d.sport[,"kugel"], d.sport[,"speer"]) plot(d.sport[,"kugel"], d.sport[,"speer"], xlab="ball~push", ylab="javelin", pch=7) pairs(d.sport)

3. Histograms. You are encouraged to play with variations of histograms. Type help(hist) or ?hist and example(hist) to see the possibilities.

a) Vary the number of classes by setting the argument nclass. Note that it determines the number of classes only approximately.

b) In order to get exactly the class breaks that you want, you need to set the argu- ment breaks. You will typically use a sequence of equidistant numbers as produced by the function seq. Try breaks = seq(13, 17, by=0.25) and other variations of your choice.

(2)

2 If it is still early to finish, you can continue by the following exercise, which will appear (modified) again next time.

4. Vectors

What is the output of the following commands? Try to predict the solutions before you type in the commands. We define:

x <- c(5,2,1,4); y <- rep(1,5);

a) sum(x) range(x) length(y) sum(y) b) c(x,y,13)

c) x[4] * y[2]

x[2:4] + x[1:3]

d) x <= 2 x[x <= 2]

5. Quit the session.

Leave the R-Session by typing q(). Answer ’Yes’ to the question.

Referenzen

ÄHNLICHE DOKUMENTE

Terminal Control Set full duplex mode Set auto repeat Set application cursor key Set Itandard cursor key Lock keyboard Unlock keyboard Soft re.et Display Control

These three processors offer increased main memory and I/O channel capacity and, according to Amdahl, an increase in throughput capacity of 1.2 to 3.6 times that of the dual

Furthermore, all KG- modules considered are assumed to be left modules and free of finite rank over K.. Proceed in the

Deduce from Remark 35.12 of the Lecture Notes that column orthogonality relations for the Brauer characters take the form Π tr Φ =

The author uf the second best Essay to receive a prize.. of five huodred rupees; and the author of the third

Basketball jerseys bea- ring the names of NBA stars are worn by youth in Europe, and the shirts of English footballers (and French, German, and Italian as well) can be seen in

60 participants have been selected for the experiment, and each participant is supposed to test and rate every packaging of exactly one toothpaste type on a 1-5 scale. Which type

120 min after drug administration. In addition a video recording of one animal in each treatment group was taken to allow post-hoc assessment of alterations in