Anda di halaman 1dari 2

# Lists available data sets

data()

data(Cars93, package = "MASS")

plot(cars)

plot(cars, main="cars: Speed vs. Stopping Distance (1920)", xlab="Speed (MPH)",


ylab="Stopping Distance (ft)", type = "n")

grid()

points(cars)

# lines(cars)

ds <- iris

summary(iris)

with(iris, plot(Petal.Length, Petal.Width))

levels(iris$Species)

with(iris, plot(Petal.Length, Petal.Width, pch = as.integer(Species)))

with(iris, legend(x = 1.5, y = 2.4, levels(Species), pch = 1:nlevels(Species)))

# scatter plot for each pair of columns

plot(iris[,1:4])

# conditioning plot

with(iris, coplot( Petal.Width ~ Petal.Length | Species))

data(Cars93, package="MASS")

coplot(Horsepower ~ MPG.city | Origin, data=Cars93)

################ BAR PLOT ################################

# barplot(c(height1, height2, ..., heightn))

barplot(c(3,5,4), col=c("red","white","blue"))

heights <- c(30,14,5,20,45)


heights <- rank(heights)/length(heights)
barplot(heights,
col=rainbow(5), ylim = c(0,50),
xpd=FALSE,
main="Mean Temp. By Month",
names.arg=c("May", "Jun", "Jul", "Aug", "Sep"),
ylab="Temp (deg. F)")
plot(cars, main="cars: Speed vs. Stopping Distance (1920)", xlab="Speed (MPH)",
ylab="Stopping Distance (ft)", type = "l")

data()

plot(pressure)

head(pressure)

plot(pressure, type="l", lty=4, lwd=3, col="blue")

############# BOX PLOT

data(UScereal, package="MASS")

head(UScereal)

boxplot(sugars ~ shelf, data=UScereal,


main="Sugar Content by Shelf",
xlab="Shelf", ylab="Sugar (grams per portion)")

data(Cars93, package="MASS")
hist(Cars93$MPG.city)

head(Cars93)

hist(Cars93$MPG.city, 12,probability = T)

samp <- rnorm(500, 15, 5)


hist(samp, 20, prob=T)
lines(density(samp))

states <- data.frame(state.region, state.x77)

Anda mungkin juga menyukai