R Handson
R Handson
R Handson
I ahvve stuck with hands-on on Data Visualization using R-1 - Plotting in R. Its
saying below instrucations but unable to run "vim code.r" command.
plot(Orange$circumference,Orange$age,xlab="Circumference",ylab="Age",pch=19,col=Ora
nge$Tree)
legend('topleft',sort(levels(Orange$Tree)),col=1:length(levels(Orange$Tree)),pch=19
)
str(cars)
summary(cars)
summary(Puromycin)
Practice plots:----
hist(cars$speed)
hist(cars$speed, breaks=10)
hist(cars$speed, breaks=4:25, main="Car Speed", xlab="Speed (mph)")
hist(cars$speed, main="Plot of Car Speed", xlab="Car Speed", border="blue",
col="green")
plot(cars$speed, cars$dist, type="p", xlab="Speed (mph)", ylab="Stopping
distance(ft)", main="Cars: Speed and stopping distance", frame.plot=FALSE)
hist(cars$speed, breaks=10, labels=TRUE)
Practice Exercise:----
par(mfrow = c(2,2))
plot(mtcars$mpg, mtcars$cyl)
plot(mtcars$mpg, mtcars$hp)
plot(mtcars$mpg, mtcars$wt)
plot(mtcars$mpg, mtcars$vs)
boxplot(mtcars$mpg, mtcars$gear)
boxplot(mtcars$mpg, mtcars$gear, notch=TRUE)
plot(cars$speed, cars$distance, xlab="Speed (mph)", ylab="Stopping distance(ft)"
main="Scatterplot Matrix",pch=8, col="brown")
abline(lm(distance~speed))
plot(cars$speed, cars$distance, xlab="Speed (mph)", ylab="Stopping distance(ft)"
main="Scatterplot Matrix",pch=8, col="brown", cex = 0.5)
library(lattice)
botplot(Var1 ~ Freq, data = VADeathRate,
groups = Var2, main = "Bar Chart in R EXample")
auto.key = list(xn5,y=0.95,legend=c("mean","5th and 95th percentiles"),
scales = list(x = list(rot = 45)),
layout = c(4,1))
install.packages("ggplot2")
library(ggplot2)
data(mpg)
qplot(cty, hwy, data=mpg, color =drv) +
geom_point(alpha = .2) +
theme_bw()