x <- seq(0, 2*pi, length.out = 20)
y <- sin(x)
plot(x, y, type="l", col="darkblue",
main="Sine Curve", sub="Copyright (c) 2016 HwB")
points(x, y, col="blue", pch=20)
lines(c(0,2*pi), c(-1,1), lty=2)
grid()
abline(h=0); abline(v=0)
?plot
worms <- read.table("../data/worms.txt", header=TRUE) # loads dataframe 'mtcars'
head(worms)
plot(worms) # scatterplot matrix
# attach(worms)
with(worms, plot(Area, Slope))
grid()
hist(worms$Soil.pH, breaks=10)
lines(density(worms$Soil.pH), col="red")
plot(worms$Vegetation, worms$Worm.density)
library(ggplot2)
qplot(worms$Area, worms$Slope)
data(mtcars) # loads dataframe 'mtcars'
str(mtcars)
plt <- ggplot(mtcars)
plt + geom_point(aes(x=disp, y=mpg, shape=factor(gear), color=cyl)) +
theme_bw()
ozdata = read.table("../data/ozone.csv", header=TRUE, sep=",")
with(ozdata,
coplot(Ozone ~ Wind|Temp, panel=panel.smooth)
)
library(lattice)
xyplot(mpg ~ disp | factor(gear), data=mtcars, layout=c(3,1))
bwplot(Worm.density ~ Soil.pH + Area | Vegetation, data=worms)
x <- seq(1, 10, by=0.5)
y <- log(x) + 0.5*(runif(length(x))-0.5)
pdf("SplineInterp.pdf")
plot(x, y, col="navy", pch=20,
main="Spline Interpolation")
lines(spline(x, y), col="red", lwd=2)
grid()
dev.off()
?pdf