SlideShare a Scribd company logo
Some Examples in R- [Data Visualization--R graphics]
and others..
library(rpart.plot),library(rCharts),library(plyr),library(knitr),
library(reshape2),library(scales)
Reference:
https://github.com/ramnathv/rCharts/tree/master/inst/libraries
http://www.rpubs.com/dnchari/rcharts
rCharts package by Ramnath Vaidyanathan
Prepared by Volkan OBAN
CODES:
require(rCharts)##Example 1
names(iris)=gsub(".","",names(iris))
rPlot(SepalLength~SepalWidth|Species,data= iris,color= 'Species',type = 'point')
Example2-
## Example 2 FacettedBarplot
hair_eye = as.data.frame(HairEyeColor)
rPlot(Freq~Hair | Eye,color = 'Eye', data = hair_eye,type = 'bar')
Example3-
require(rCharts)
> names(iris) = gsub(".", "", names(iris))
> rPlot(SepalLength ~ SepalWidth | Species, data = iris, color = 'Speci
es', type = 'point')
> ## Example 2 Facetted Barplot
> hair_eye = as.data.frame(HairEyeColor)
> rPlot(Freq ~ Hair | Eye, color = 'Eye', data = hair_eye, type = '
bar')
> hair_eye = as.data.frame(HairEyeColor)
> p2 <- nPlot(Freq ~ Hair, group = 'Eye',
+ data = subset(hair_eye, Sex == "Female"),
+ type = 'multiBarChart'
+ )
> p2$chart(color = c('brown', 'blue', '#594c26', 'green'))
> p2
Example 4:
p <- nPlot(~ cyl, data = mtcars, type = 'pieChart')
> p$chart(donut = TRUE
> p5
Example 5:
data(economics, package = 'ggplot2')
> p <- nPlot(uempmed ~ date, data = economics, type = 'lineChart')
> p
Example6:
dat <- data.frame(
t = rep(0:23, each= 4),
var = rep(LETTERS[1:4],4),
val = round(runif(4*24,0,50)) )
p<- nPlot(val ~t,group = 'var', data = dat, type = 'stackedAreaChart',id='chart' )
p
 Some Examples in R- [Data Visualization--R graphics]
 Some Examples in R- [Data Visualization--R graphics]
Example 7:
require(rCharts)
> p1 <- rPlot(SOG ~ yearID, data = team_data,
+ type = "point",
+ size = list(const = 2),
+ color = list(const = "#888"),
+ tooltip = "#! function(item){
+ return item.SOG + ' ' + item.name + ' ' + item.yearID
+ } !#"
+ )
> p1
> myteam = "Boston Red Sox"
> p1$layer(data = team_data[team_data$name == myteam,],
+ color = list(const = 'red'),
+ copy_layer = T)
> p1$set(dom = 'chart3')
> p1
>
Example 8:
>
> library(rCharts)
> library(plyr)
> library(knitr)
> library(reshape2)
> library(scales)
> options(RCHART_WIDTH = 600, RCHART_HEIGHT = 400)
> knitr::opts_chunk$set(comment = NA, results = 'asis', tidy = F, message =
F)
> data(tips, package = 'reshape2')
p= rPlot(x = 'day', y = 'box(tip)', data = tips, type = 'box')
> p
nba = read.csv('http://datasets.flowingdata.com/ppg2008.csv')
> nba.m = ddply(melt(nba), .(variable), transform, rescale = rescale(value)
)
> p= rPlot(Name ~ variable, color = 'rescale', data = nba.m, type = 'tile',
height = 600)
> p
Example:
haireye = as.data.frame(HairEyeColor)
> dat = subset(haireye, Sex == "Female" & Eye == "Blue")
> haireye = as.data.frame(HairEyeColor)
> dat = subset(haireye, Sex == "Female" & Eye == "Blue")
> p1 = mPlot(x = 'Hair', y = list('Freq'), data = dat, type = 'Bar', labels = list("Cou
> p1
dat = subset(haireye, Sex == "Female")
p2 = mPlot(Freq ~ Eye, group = "Hair", data = dat, type = "Bar", labels = 1
:4)
p2
Example:
data(economics, package = 'ggplot2')
dat = transform(economics, date = as.character(date))
p3 <- mPlot(x = "date", y = list("psavert", "uempmed"), data = dat, type =
'Line',
pointSize = 0, lineWidth = 1)
p3$set(xLabelFormat = "#! function (x) {
return x.toString(); }
!#")
p3$set(type = 'Area')
p3
Example:
ecm = reshape2::melt(economics[,c('date', 'uempmed', 'psavert')], id = 'dat
e')
p7 = nPlot(value ~ date, group = 'variable', data = ecm, type = 'lineWithFo
cusChart')
p7$xAxis( tickFormat="#!function(d) {return d3.time.format('%b %Y')(new Dat
e( d * 86400000 ));}!#" )
p7
Example:
library(rpart.plot)
h= hPlot(x = "Wr.Hnd", y = "NW.Hnd", data = MASS::survey,
+ type = c("line", "bubble", "scatter"), group = "Clap", size =
"Age")
h
> map3 = Leaflet$new()
> map3$setView(c(41.7627, -72.6743), zoom = 13)
> map3$marker(c(41.7627, -72.6743), bindPopup = "<p> Hi. I am a popup </p>"
)
> map3$marker(c(41.70, -72.60), bindPopup = "<p> Hi. I am another popup </p
>")
> map3
> map3 = Leaflet$new()
> map3$setView(c(41.7627, -72.6743), zoom = 13)
> map3$marker(c(41.7627, -72.6743), bindPopup = "<p> Hi. I am a popup </p>"
)
> map3$marker(c(41.70, -72.60), bindPopup = "<p> Hi. I am another popup </p
>")
> map3
Example:
> map3 = Leaflet$new()
> map3$setView(c(41.7627, -72.6743), zoom = 13)
> map3$marker(c(41.7627, -72.6743), bindPopup = "<p> Hi. I am a popup </p>"
)
> map3$marker(c(41.70, -72.60), bindPopup = "<p> Hi. I am another popup </p
>")
> map3
Reference:
https://github.com/ramnathv/rCharts/tree/master/inst/libraries
http://www.rpubs.com/dnchari/rcharts
rCharts package by Ramnath Vaidyanathan

More Related Content

DOCX
ggplot2 extensions-ggtree.
PPTX
Hacking the Internet of Things for Fun & Profit
PDF
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
PDF
Angular Refactoring in Real World
KEY
第49回Php勉強会@関東 Datasource
PDF
How to calculate the optimal undo retention in Oracle
PPTX
Using R for Building a Simple and Effective Dashboard
DOCX
Plot3D Package and Example in R.-Data visualizat,on
ggplot2 extensions-ggtree.
Hacking the Internet of Things for Fun & Profit
Some R Examples[R table and Graphics] -Advanced Data Visualization in R (Some...
Angular Refactoring in Real World
第49回Php勉強会@関東 Datasource
How to calculate the optimal undo retention in Oracle
Using R for Building a Simple and Effective Dashboard
Plot3D Package and Example in R.-Data visualizat,on

What's hot (20)

DOCX
Advanced Data Visualization Examples with R-Part II
ODP
Cache and Drupal
PDF
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
PPT
Prgišče Lispa
ODP
Как показать 90 млн картинок и сохранить жизнь диску
ODP
Как показать 90 млн картинок и сохранить жизнь диску
DOCX
Advanced Data Visualization in R- Somes Examples.
PDF
strings and objects in JavaScript
PDF
LINE iOS開発で実践しているGit tips
PPT
Database api
KEY
Zf Zend Db by aida
PPTX
R seminar dplyr package
KEY
重回帰職人の朝は早い
PDF
Py lecture5 python plots
PPTX
Hive Poster
KEY
R meets Hadoop
TXT
pROgRAN C++ ApLiKaSI Binery tree
PDF
JSDC 2014 - functional java script, why or why not
PPTX
Building a horizontally scalable API in php
Advanced Data Visualization Examples with R-Part II
Cache and Drupal
Wat.tf - Nati Cohen - DevOpsDays Tel Aviv 2018
Prgišče Lispa
Как показать 90 млн картинок и сохранить жизнь диску
Как показать 90 млн картинок и сохранить жизнь диску
Advanced Data Visualization in R- Somes Examples.
strings and objects in JavaScript
LINE iOS開発で実践しているGit tips
Database api
Zf Zend Db by aida
R seminar dplyr package
重回帰職人の朝は早い
Py lecture5 python plots
Hive Poster
R meets Hadoop
pROgRAN C++ ApLiKaSI Binery tree
JSDC 2014 - functional java script, why or why not
Building a horizontally scalable API in php
Ad

Similar to Some Examples in R- [Data Visualization--R graphics] (20)

DOCX
A Shiny Example-- R
DOCX
library(sparkline)
PDF
Implementing virtual machines in go & c 2018 redux
PDF
Refactoring to Macros with Clojure
PPT
A Survey Of R Graphics
PDF
Joclad 2010 d
PDF
Perl6 Regexen: Reduce the line noise in your code.
DOCX
Spark_Documentation_Template1
DOCX
ggtimeseries-->ggplot2 extensions
PPTX
Php functions
PDF
Big Data Analytics with Scala at SCALA.IO 2013
PDF
Implementing Software Machines in C and Go
PPT
JBUG 11 - Scala For Java Programmers
PDF
R for you
DOCX
R (Shiny Package) - Server Side Code for Decision Support System
DOCX
PHP record- with all programs and output
PPTX
Spark by Adform Research, Paulius
KEY
Achieving Parsing Sanity In Erlang
PDF
Imugi: Compiler made with Python
PDF
Abap basics 01
A Shiny Example-- R
library(sparkline)
Implementing virtual machines in go & c 2018 redux
Refactoring to Macros with Clojure
A Survey Of R Graphics
Joclad 2010 d
Perl6 Regexen: Reduce the line noise in your code.
Spark_Documentation_Template1
ggtimeseries-->ggplot2 extensions
Php functions
Big Data Analytics with Scala at SCALA.IO 2013
Implementing Software Machines in C and Go
JBUG 11 - Scala For Java Programmers
R for you
R (Shiny Package) - Server Side Code for Decision Support System
PHP record- with all programs and output
Spark by Adform Research, Paulius
Achieving Parsing Sanity In Erlang
Imugi: Compiler made with Python
Abap basics 01
Ad

More from Dr. Volkan OBAN (20)

PDF
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
PDF
Covid19py Python Package - Example
PDF
Object detection with Python
PDF
Python - Rastgele Orman(Random Forest) Parametreleri
DOCX
Linear Programming wi̇th R - Examples
DOCX
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
DOCX
k-means Clustering in Python
DOCX
Naive Bayes Example using R
DOCX
R forecasting Example
DOCX
k-means Clustering and Custergram with R
PDF
Data Science and its Relationship to Big Data and Data-Driven Decision Making
DOCX
Data Visualization with R.ggplot2 and its extensions examples.
PDF
Scikit-learn Cheatsheet-Python
PDF
Python Pandas for Data Science cheatsheet
PDF
Pandas,scipy,numpy cheatsheet
PPTX
ReporteRs package in R. forming powerpoint documents-an example
PPTX
ReporteRs package in R. forming powerpoint documents-an example
DOCX
R-ggplot2 package Examples
DOCX
R Machine Learning packages( generally used)
DOCX
treemap package in R and examples.
Conference Paper:IMAGE PROCESSING AND OBJECT DETECTION APPLICATION: INSURANCE...
Covid19py Python Package - Example
Object detection with Python
Python - Rastgele Orman(Random Forest) Parametreleri
Linear Programming wi̇th R - Examples
"optrees" package in R and examples.(optrees:finds optimal trees in weighted ...
k-means Clustering in Python
Naive Bayes Example using R
R forecasting Example
k-means Clustering and Custergram with R
Data Science and its Relationship to Big Data and Data-Driven Decision Making
Data Visualization with R.ggplot2 and its extensions examples.
Scikit-learn Cheatsheet-Python
Python Pandas for Data Science cheatsheet
Pandas,scipy,numpy cheatsheet
ReporteRs package in R. forming powerpoint documents-an example
ReporteRs package in R. forming powerpoint documents-an example
R-ggplot2 package Examples
R Machine Learning packages( generally used)
treemap package in R and examples.

Recently uploaded (20)

PPTX
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
PPTX
Introduction to machine learning and Linear Models
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PDF
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
SAP 2 completion done . PRESENTATION.pptx
PPTX
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
PDF
Mega Projects Data Mega Projects Data
PPTX
IB Computer Science - Internal Assessment.pptx
PPTX
1_Introduction to advance data techniques.pptx
PPT
Reliability_Chapter_ presentation 1221.5784
PPT
ISS -ESG Data flows What is ESG and HowHow
PDF
Introduction to the R Programming Language
PDF
Fluorescence-microscope_Botany_detailed content
PDF
annual-report-2024-2025 original latest.
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
Database Infoormation System (DBIS).pptx
PPTX
Acceptance and paychological effects of mandatory extra coach I classes.pptx
PDF
Clinical guidelines as a resource for EBP(1).pdf
MODULE 8 - DISASTER risk PREPAREDNESS.pptx
Introduction to machine learning and Linear Models
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
Recruitment and Placement PPT.pdfbjfibjdfbjfobj
Data_Analytics_and_PowerBI_Presentation.pptx
SAP 2 completion done . PRESENTATION.pptx
AI Strategy room jwfjksfksfjsjsjsjsjfsjfsj
Mega Projects Data Mega Projects Data
IB Computer Science - Internal Assessment.pptx
1_Introduction to advance data techniques.pptx
Reliability_Chapter_ presentation 1221.5784
ISS -ESG Data flows What is ESG and HowHow
Introduction to the R Programming Language
Fluorescence-microscope_Botany_detailed content
annual-report-2024-2025 original latest.
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Introduction to Knowledge Engineering Part 1
Database Infoormation System (DBIS).pptx
Acceptance and paychological effects of mandatory extra coach I classes.pptx
Clinical guidelines as a resource for EBP(1).pdf

Some Examples in R- [Data Visualization--R graphics]

  • 1. Some Examples in R- [Data Visualization--R graphics] and others.. library(rpart.plot),library(rCharts),library(plyr),library(knitr), library(reshape2),library(scales) Reference: https://github.com/ramnathv/rCharts/tree/master/inst/libraries http://www.rpubs.com/dnchari/rcharts rCharts package by Ramnath Vaidyanathan Prepared by Volkan OBAN
  • 2. CODES: require(rCharts)##Example 1 names(iris)=gsub(".","",names(iris)) rPlot(SepalLength~SepalWidth|Species,data= iris,color= 'Species',type = 'point') Example2- ## Example 2 FacettedBarplot hair_eye = as.data.frame(HairEyeColor) rPlot(Freq~Hair | Eye,color = 'Eye', data = hair_eye,type = 'bar')
  • 3. Example3- require(rCharts) > names(iris) = gsub(".", "", names(iris)) > rPlot(SepalLength ~ SepalWidth | Species, data = iris, color = 'Speci es', type = 'point') > ## Example 2 Facetted Barplot > hair_eye = as.data.frame(HairEyeColor) > rPlot(Freq ~ Hair | Eye, color = 'Eye', data = hair_eye, type = ' bar') > hair_eye = as.data.frame(HairEyeColor) > p2 <- nPlot(Freq ~ Hair, group = 'Eye', + data = subset(hair_eye, Sex == "Female"), + type = 'multiBarChart' + ) > p2$chart(color = c('brown', 'blue', '#594c26', 'green')) > p2
  • 4. Example 4: p <- nPlot(~ cyl, data = mtcars, type = 'pieChart') > p$chart(donut = TRUE > p5
  • 5. Example 5: data(economics, package = 'ggplot2') > p <- nPlot(uempmed ~ date, data = economics, type = 'lineChart') > p
  • 6. Example6: dat <- data.frame( t = rep(0:23, each= 4), var = rep(LETTERS[1:4],4), val = round(runif(4*24,0,50)) ) p<- nPlot(val ~t,group = 'var', data = dat, type = 'stackedAreaChart',id='chart' ) p
  • 9. Example 7: require(rCharts) > p1 <- rPlot(SOG ~ yearID, data = team_data, + type = "point", + size = list(const = 2), + color = list(const = "#888"), + tooltip = "#! function(item){ + return item.SOG + ' ' + item.name + ' ' + item.yearID + } !#" + ) > p1
  • 10. > myteam = "Boston Red Sox" > p1$layer(data = team_data[team_data$name == myteam,], + color = list(const = 'red'), + copy_layer = T) > p1$set(dom = 'chart3') > p1 >
  • 11. Example 8: > > library(rCharts) > library(plyr) > library(knitr) > library(reshape2) > library(scales) > options(RCHART_WIDTH = 600, RCHART_HEIGHT = 400) > knitr::opts_chunk$set(comment = NA, results = 'asis', tidy = F, message = F) > data(tips, package = 'reshape2') p= rPlot(x = 'day', y = 'box(tip)', data = tips, type = 'box') > p
  • 12. nba = read.csv('http://datasets.flowingdata.com/ppg2008.csv') > nba.m = ddply(melt(nba), .(variable), transform, rescale = rescale(value) ) > p= rPlot(Name ~ variable, color = 'rescale', data = nba.m, type = 'tile', height = 600) > p
  • 13. Example: haireye = as.data.frame(HairEyeColor) > dat = subset(haireye, Sex == "Female" & Eye == "Blue") > haireye = as.data.frame(HairEyeColor) > dat = subset(haireye, Sex == "Female" & Eye == "Blue") > p1 = mPlot(x = 'Hair', y = list('Freq'), data = dat, type = 'Bar', labels = list("Cou > p1
  • 14. dat = subset(haireye, Sex == "Female") p2 = mPlot(Freq ~ Eye, group = "Hair", data = dat, type = "Bar", labels = 1 :4) p2
  • 15. Example: data(economics, package = 'ggplot2') dat = transform(economics, date = as.character(date)) p3 <- mPlot(x = "date", y = list("psavert", "uempmed"), data = dat, type = 'Line', pointSize = 0, lineWidth = 1) p3$set(xLabelFormat = "#! function (x) { return x.toString(); } !#") p3$set(type = 'Area') p3
  • 16. Example: ecm = reshape2::melt(economics[,c('date', 'uempmed', 'psavert')], id = 'dat e') p7 = nPlot(value ~ date, group = 'variable', data = ecm, type = 'lineWithFo cusChart') p7$xAxis( tickFormat="#!function(d) {return d3.time.format('%b %Y')(new Dat e( d * 86400000 ));}!#" ) p7
  • 17. Example: library(rpart.plot) h= hPlot(x = "Wr.Hnd", y = "NW.Hnd", data = MASS::survey, + type = c("line", "bubble", "scatter"), group = "Clap", size = "Age") h > map3 = Leaflet$new() > map3$setView(c(41.7627, -72.6743), zoom = 13) > map3$marker(c(41.7627, -72.6743), bindPopup = "<p> Hi. I am a popup </p>" ) > map3$marker(c(41.70, -72.60), bindPopup = "<p> Hi. I am another popup </p >") > map3 > map3 = Leaflet$new() > map3$setView(c(41.7627, -72.6743), zoom = 13) > map3$marker(c(41.7627, -72.6743), bindPopup = "<p> Hi. I am a popup </p>" ) > map3$marker(c(41.70, -72.60), bindPopup = "<p> Hi. I am another popup </p >") > map3
  • 18. Example: > map3 = Leaflet$new() > map3$setView(c(41.7627, -72.6743), zoom = 13) > map3$marker(c(41.7627, -72.6743), bindPopup = "<p> Hi. I am a popup </p>" ) > map3$marker(c(41.70, -72.60), bindPopup = "<p> Hi. I am another popup </p >") > map3