library(DAAG) roller plot(depression ~ weight, data=roller) plot(roller) # 1st column is x; 2nd column is y plot(density(rnorm(50))) class(density(rnorm(50))) plot(density(rnorm(200))) plot(density(rnorm(2000))) with(data.frame(x=seq(from=-3.5, to=3.5, by=50)), lines(x, dnorm(x), col="red")) curve(dnorm, from=-3.5, to=3.5, add=TRUE, col="purple") curve(pnorm, from=-3.5, to=3.5) curve(qnorm, from=0, to=1) curve(dnorm, from=-5, to=5) fn <- function(x)dt(x, df=2) curve(fn, from=-5, to=5, col="green", add=T, lwd=4) fn <- function(x)dt(x, df=5) curve(fn, from=-5, to=5, col="blue", add=T, lwd=3) fn <- function(x)dt(x, df=10) curve(fn, from=-5, to=5, col="magenta", add=T, lwd=2) legend("topleft", legend=c("2","5","10","Inf"), lty=rep(1,4), lwd=4:1, text.col=c("green","blue","magenta","black"), col=c("green","blue","magenta","black")) plot(density(rexp(50))) plot(density(rexp(200))) plot(density(rexp(200), from=0)) curve(dexp, from=0, to=6) plot(density(science$like)) qqnorm(science$like) plot(qnorm(ppoints(length(science$like))), sort(science$like)) ppoints(5) avs <- simulateSampDist() plotSampDist(avs) avs <- simulateSampDist(science$like) plotSampDist(avs) roller.lm <- lm(depression ~ weight, data=roller) roller.lm model.matrix(roller.lm) plot(roller.lm) termplot(roller.lm) library(MASS) plot(Animals) plot(Animals, log="xy") with(Animals, identify(brain~body, labels=row.names(Animals))) Animals.lm <- lm(log10(brain) ~ log10(body), data=Animals, subset=!row.names(Animals) %in%c("Brachiosaurus", "Triceratops", "Dipliodocus"))