Primer uporabe Sweave

Page 1

Primer uporabe Sweave A. Blejec December 3, 2008 Abstract Minimalna datoteka za uporabo Sweave: povezava R in LATEX.

1

Raˇ cunanje

Poskus raˇcunanja > 2 + 2 [1] 4

2

Risanje

Malo risanja: > hist(rnorm(100), col = "lightblue")

15 10 5 0

Frequency

20

25

Histogram of rnorm(100)

−3

−2

−1

0 rnorm(100)

1

1

2

3


3

Uporaba vrednosti v besedilu

Primerjava dveh porazdelitev (R ukazi so skriti) Welch Two Sample t-test data: x and y t = 0.9746, df = 50.628, p-value = 0.3344 alternative hypothesis: true difference in means is not equal to 0 95 percent confidence interval: -2.871863 8.288695 sample estimates: mean of x mean of y 97.71451 95.00609 Vrednosti iz R objektov lahko uporabimo v besedilu. Na primer: Verjetnost p = 0.334.

4

Tabele

Za pripravo tabel z LATEX je priroˇcno namestiti paket Hmisc > library("Hmisc") > tbl <- table(letters[round(runif(100, 1, 3))], LETTERS[round(runif(100, + 1, 3))]) > tbl

a b c

A B 8 10 5 36 7 14

C 7 8 5

Tabele lahko izpiˇse tudi LATEX: > latex(tbl, file = "", where = "!htbp", caption = "Poskusna tabela")

Table 1: Poskusna tabela tbl a b c

5

A 8 5 7

B 10 36 14

Zakljuˇ cek

Sweave je zakon! 2

C 7 8 5


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.