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:
#install.packages("ggplot2")
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.2
#install.packages("reshape")
library(reshape)
## Warning: package 'reshape' was built under R version 3.5.2
View(mpg)
mpg<-rename(mpg,c(trans="Transmission"))
g <- ggplot(mpg, aes(class))
g + geom_bar(aes(fill = Transmission))
mpg<-rename(mpg,c(manufacturer="Vehicle Manufacturer"))
mpg<-rename(mpg,c(hwy="Highway Efficiency Fuel(miles/gallon)"))
p <- ggplot(mpg, aes(`Vehicle Manufacturer`, `Highway Efficiency Fuel(miles/gallon)`))
p + geom_boxplot() + coord_flip() +theme(axis.line = element_line(colour = "black") ,panel.background = element_rect(fill = NA))
#install.packages("ggthemes")
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 3.5.2
diamonds<-rename(diamonds,c(price="Diamond Price (USD)"))
p<-ggplot(diamonds, aes(`Diamond Price (USD)`, fill =cut, colour = cut)) +
geom_density(alpha=0.3) +labs(title="Diamonds Price Density")
p + theme_economist()
#install.packages("ISLR")
#install.packages("MASS")
library(MASS)
## Warning: package 'MASS' was built under R version 3.5.2
library(ISLR)
## Warning: package 'ISLR' was built under R version 3.5.2
p<-ggplot(iris,aes(x=Sepal.Length, y=Petal.Length))+geom_point()
p + labs(title = "Relationship between Petal and Sepal Length", x= "iris Sepal Length", y="iris Petal Length") + geom_smooth(method="lm") + theme_minimal()
m<-ggplot(data= iris,aes(x=Sepal.Length, y=Petal.Length,color=Species))+ geom_point() +geom_smooth(method = "lm")
m + labs(title = "Relationship between Petal and Sepal Length", x= "iris Sepal Length", y="iris Petal Length" , subtitle = "Species level comparison") + theme(panel.background = element_rect(fill = NA), legend.position = "bottom")