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:
library(RColorBrewer)
data(VADeaths)
head(VADeaths)
## Rural Male Rural Female Urban Male Urban Female
## 50-54 11.7 8.7 15.4 8.4
## 55-59 18.1 11.7 24.3 13.6
## 60-64 26.9 20.3 37.0 19.3
## 65-69 41.0 30.9 54.6 35.1
## 70-74 66.0 54.3 71.1 50.0
#Histogram
par(mfrow=c(2,3))
hist(VADeaths,breaks=10, col=brewer.pal(3,"Set3"),main="Set3 3 colors")
hist(VADeaths,breaks=3 ,col=brewer.pal(3,"Set2"),main="Set2 3 colors")
hist(VADeaths,breaks=7, col=brewer.pal(3,"Set1"),main="Set1 3 colors")
hist(VADeaths,,breaks= 2, col=brewer.pal(8,"Set3"),main="Set3 8 colors")
hist(VADeaths,col=brewer.pal(8,"Greys"),main="Greys 8 colors")
hist(VADeaths,col=brewer.pal(8,"Greens"),main="Greens 8 colors")
#Linechart
plot(AirPassengers,type="l")
#Barplot
par(mfrow=c(2,2))
barplot(iris$Petal.Length)
barplot(iris$Sepal.Length,col = brewer.pal(3,"Set1"))
barplot(table(iris$Species,iris$Sepal.Length),col = brewer.pal(3,"Set1"))
#Boxplot
boxplot(iris$Petal.Length~iris$Species)
data(iris)
par(mfrow=c(2,2))
boxplot(iris$Sepal.Length,col="red")
boxplot(iris$Sepal.Length~iris$Species,col="red")
boxplot(iris$Sepal.Length~iris$Species,col=heat.colors(3))
boxplot(iris$Sepal.Length~iris$Species,col=topo.colors(3))
#Scatterplot
plot(x=iris$Petal.Length)
plot(x=iris$Petal.Length,y=iris$Species)
plot(iris,col=brewer.pal(3,"Set1"))
#Piechart
pie(table(iris$Species))
library("hexbin")
## Warning: package 'hexbin' was built under R version 3.4.3
library("ggplot2")
a=hexbin(diamonds$price,diamonds$carat,xbins=40)
library(RColorBrewer)
plot(a)
rf <- colorRampPalette(rev(brewer.pal(40,'Set3')))
## Warning in brewer.pal(40, "Set3"): n too large, allowed maximum for palette Set3 is 12
## Returning the palette you asked for with that many colors
hexbinplot(diamonds$price~diamonds$carat, data=diamonds, colramp=rf)
#Mosaic plot
data(HairEyeColor)
mosaicplot(HairEyeColor)
#Heat map
data("mtcars")
heatmap(as.matrix(mtcars))
image(as.matrix(mtcars[2:7]))
#Tableplot
library("tabplot")
## Warning: package 'tabplot' was built under R version 3.4.3
## Loading required package: bit
## Attaching package bit
## package:bit (c) 2008-2012 Jens Oehlschlaegel (GPL-2)
## creators: bit bitwhich
## coercion: as.logical as.integer as.bit as.bitwhich which
## operator: ! & | xor != ==
## querying: print length any all min max range sum summary
## bit access: length<- [ [<- [[ [[<-
## for more help type ?bit
##
## Attaching package: 'bit'
## The following object is masked from 'package:base':
##
## xor
## Loading required package: ff
## Warning: package 'ff' was built under R version 3.4.3
## Attaching package ff
## - getOption("fftempdir")=="C:/Users/HP/AppData/Local/Temp/Rtmp21mnS8"
## - getOption("ffextension")=="ff"
## - getOption("ffdrop")==TRUE
## - getOption("fffinonexit")==TRUE
## - getOption("ffpagesize")==65536
## - getOption("ffcaching")=="mmnoflush" -- consider "ffeachflush" if your system stalls on large writes
## - getOption("ffbatchbytes")==84745912.32 -- consider a different value for tuning your system
## - getOption("ffmaxbytes")==4237295616 -- consider a different value for tuning your system
##
## Attaching package: 'ff'
## The following objects are masked from 'package:bit':
##
## clone, clone.default, clone.list
## The following objects are masked from 'package:utils':
##
## write.csv, write.csv2
## The following objects are masked from 'package:base':
##
## is.factor, is.ordered
## Loading required package: ffbase
## Warning: package 'ffbase' was built under R version 3.4.3
##
## Attaching package: 'ffbase'
## The following objects are masked from 'package:ff':
##
## [.ff, [.ffdf, [<-.ff, [<-.ffdf
## The following objects are masked from 'package:base':
##
## %in%, table
tableplot(mtcars)
## Warning in tableplot_checkBins(nBins, max(N, 2)): Setting nBins (100) to
## number of rows (32)
#devtools::install_github("rstudio/leaflet")
#install.packages("magrittr")
#install.packages("leaflet")
library(magrittr)
## Warning: package 'magrittr' was built under R version 3.4.3
##
## Attaching package: 'magrittr'
## The following object is masked from 'package:ff':
##
## add
library(leaflet)
m <- leaflet() %>%
addTiles() %>% # Add default OpenStreetMap map tiles
addMarkers(lng=77.2310, lat=28.6560, popup="The delicious food of chandni chowk")
m
#install.packages("Rcmdr")
#library("Rcmdr")
library("car")
## Warning: package 'car' was built under R version 3.4.2
#install.packages("rgl")
library("rgl")
## Warning: package 'rgl' was built under R version 3.4.3
data(iris, package="datasets")
scatter3d(Petal.Width~Petal.Length+Sepal.Length|Species, data=iris, fit="linear",
residuals=TRUE, parallel=FALSE, bg="black", axis.scales=TRUE, grid=TRUE, ellipsoid=FALSE)
#install.packages("lattice")
library("lattice")
## Warning: package 'lattice' was built under R version 3.4.3
attach(iris)
cloud(Sepal.Length~Sepal.Width*Petal.Length|Species, main="3D Scatterplot by Species")
xyplot(Sepal.Width ~ Sepal.Length, iris, groups = iris$Species, pch= 20)
#install.packages("corrgram")
library("corrgram")
## Warning: package 'corrgram' was built under R version 3.4.3
#install.packages("scales")
library("scales")
## Warning: package 'scales' was built under R version 3.4.3
cor(iris[1:4])
## Sepal.Length Sepal.Width Petal.Length Petal.Width
## Sepal.Length 1.0000000 -0.1175698 0.8717538 0.8179411
## Sepal.Width -0.1175698 1.0000000 -0.4284401 -0.3661259
## Petal.Length 0.8717538 -0.4284401 1.0000000 0.9628654
## Petal.Width 0.8179411 -0.3661259 0.9628654 1.0000000
corrgram(iris)