Projekt R pro statistické výpočty - grafy jednoduchých funkcí: Porovnání verzí

Z GeoWikiCZ
(+histogram)
Řádek 28: Řádek 28:


== Histogram ==
== Histogram ==
data <- c (1.64, 3.84, 5.93, 7.98, 9.54, 6.98, 4.99, 3.28,
                2.25, 2.13, 4.58, 6.60, 7.72, 8.88, 8.56, 5.47,
                3.59, 7.43, 4.31, 4.68, 6.10, 6.43, 5.43, 5.33, 5.69)
hist (data, breaks=9, plot=FALSE)
hist (data, breaks=9, plot=TRUE,
        col = "grey",
        main = "Histogram", sub = "Produced by R", xlab="x", ylab="y",
        cex.sub = .6, cex.main = .9, cex.lab = .8, cex.axis = .75)


[ [[Projekt R pro statistické výpočty|zpět]] ]
[ [[Projekt R pro statistické výpočty|zpět]] ]

Verze z 26. 3. 2006, 21:57

Obecné poznámky

  • nápověda je dostupná pomocí funkce help.start (), manuálová stránka konkrétní funkce, např. plot () potom help (plot).
  • výstup do formátu PNG
png ('nazev_souboru.png', width=640, height=480)

...
plot ()
...

dev.off ()

Poznámka: podobně lze vytvořit výstupní soubor ve formátu PostScript a dalších, viz help (Devices).

Průběh funkce y = sqrt (1+x)

x <- seq  (-1, 1, by = 0.05)
y <- sqrt (1 + x)

plot (x, y,
      type = "l", lwd = 2, col = "red",
      main = "y = sqrt (1 + x)", sub = "Produced by R",
      cex.sub = .6, cex.main = .9, cex.lab = .8, cex.axis = .75)
Obrázek: Průběh funkce y = sqrt (1+x)

Histogram

data <- c (1.64, 3.84, 5.93, 7.98, 9.54, 6.98, 4.99, 3.28,
                2.25, 2.13, 4.58, 6.60, 7.72, 8.88, 8.56, 5.47,
                3.59, 7.43, 4.31, 4.68, 6.10, 6.43, 5.43, 5.33, 5.69)

hist (data, breaks=9, plot=FALSE)

hist (data, breaks=9, plot=TRUE,
        col = "grey",
        main = "Histogram", sub = "Produced by R", xlab="x", ylab="y", 
        cex.sub = .6, cex.main = .9, cex.lab = .8, cex.axis = .75)

[ zpět ]