Contenu connexe Similaire à (Very) Basic graphing with R Similaire à (Very) Basic graphing with R (20) Plus de Kazuki Yoshida (13) (Very) Basic graphing with R1. Graphing
with
2012-11-19 @HSPH
Kazuki Yoshida, M.D.
MPH-CLE student
FREEDOM
TO
KNOW
3. Previously in this group
n Introduction
n Reading Data into R (1)
n Reading Data into R (2)
n Descriptive, continuous
n Descriptive, categorical
Group Website: http://rpubs.com/kaz_yos/useR_at_HSPH
5. Ingredients
Statistics Programming
n One-variable plot n base, lattice, and ggplot2
n Histogram n hist(), histogram()
n Density plot n densityplot()
n Two-variable plot n plot(Y~X)
n Scatter plot n boxplot(), bwplot()
n Box plot n Conditioning in lattice
n Grouped plot
8. lattice package
http://zoonek.free.fr/blosxom/R/2006-08-10_R_Graphics.html
12. Download comma-separated and Excel
Put them in folder
BONEDEN.DAT.txt
BETACAR.DAT.txt
http://www.cengage.com/cgi-wadsworth/course_products_wp.pl?
fid=M20bI&product_isbn_issn=9780538733496
21. ## base
plot(fn1 ~ age, bone)
## lattice
xyplot(fn1 ~ age, bone)
## ggplot2
qplot(age, fn1, data = bone)
23. ## base
boxplot(Wk12lvl ~ Prepar, vitA)
## lattice
bwplot(Wk12lvl ~ factor(Prepar), vitA)
## ggplot2
qplot(factor(Prepar), Wk12lvl, data = vitA,
geom = "boxplot")
25. ## base
layout(matrix(1:4,ncol = 2))
for (i in 1:4) {
plot(Wk12lvl ~ Base1lvl, subset(vitA, Prepar == i))
title(paste("Prepar = ", i))
}
## lattice
xyplot(Wk12lvl ~ Base1lvl | factor(Prepar), vitA)
## ggplot2
ggplot(vitA, aes(x = Base1lvl, y = Wk12lvl, group = factor(Prepar)))
+ geom_point() + facet_wrap(~Prepar)