This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
You can also embed plots, for example:
#Vis 1
g <- ggplot(mpg, aes(class))
g + geom_bar(aes(fill = trans))
#Vis 2
g <- ggplot(mpg, aes(x=manufacturer,y=hwy)) + geom_boxplot() +
guides(fill=FALSE) + coord_flip() + scale_x_discrete(name="Vehicle Manufacturer") + scale_y_continuous(name="Highway Fuel Efficiency (miles/gallon)")
g
#Vis 3
library(ggplot2)
cbPalette <- c("#999999", "#E69F00", "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")
p <- qplot(price, data = diamonds, geom = "density", fill = cut) + theme(legend.position="top", panel.background = element_rect(fill = '#d5e5eb'), plot.background = element_rect(fill = '#d5e5eb'), legend.background = element_rect(fill = '#d5e5eb'),panel.grid.minor = element_blank(),panel.grid.major.x = element_blank(), plot.title = element_text(face="bold", size=16)) + labs(x="Diamond Price (USD)",y="Density") + geom_density(alpha = 0.1) + ggtitle('Diamond Price Density')
p
#Vis 4
p <- ggplot(iris, aes(x = Sepal.Length, y = Petal.Length)) + geom_point() + geom_smooth(method = "lm") + labs(x="Iris Sepal Length", y="Iris Petal Length") + ggtitle('Relationship between Petal and Sepal Length') + theme_bw() +theme(panel.border = element_blank(),axis.ticks = element_blank())
p
#Vis 5
p <- ggplot(data=iris, aes(x = Sepal.Length, y = Petal.Length, color=Species), main="text") + geom_point() + scale_colour_hue(l=50) + geom_smooth(method=lm, se=FALSE) + labs(x="Iris Sepal Length", y="Iris Petal Length", title = "Relationship between Petal and Sepal Length", subtitle = "Species level comparison") + theme_bw() +theme(legend.position="bottom", panel.border = element_blank(), panel.grid.minor = element_blank(),panel.grid.major = element_blank(),text=element_text(family="Times"))
p