SlideShare a Scribd company logo
1 of 14
Download to read offline
R Graphics
Practice and Theory
Monday, March 26, 2012



Novi Reandy Sasmita
novireandysasmita@gmail.com
http://www.researchgate.net/profile/Novi_Sasmita
R Graphics: Data
R Graphics: Data
  > indicators=c("Total Assets (trillions of Rp)","Deposits(trillions of Rp)","Credit (trillions of Rp)", "loan to Deposit
  Ratio-LDR (%)","Return on Assets-ROA (%)", "Non Performing Loans-NPL (%)","Capital Adequacy Ratio-CAR (%)")
  > data2001=c(1099.7, 797.4, 358.6, 45.0, 1.4, 12.1, 20.5)
  > data2000=c(1030.5, 699.1, 320.5, 45.8, 0.9, 18.8, 12.7)
  > data2001=c(1099.7, 797.4, 358.6, 45.0, 1.4, 12.1, 20.5)
  > data2002=c(1112.2, 853.8, 410.3, 49.1, 1.9, 8.1, 22.5)
  > data2003=c(1196.2, 888.6, 477.2, 53.7, 2.5, 8.2, 19.4)
  > data2004=c(1272.3, 963.1, 596.1, 61.8, 3.5, 5.8, 19.4)
  > data2005=c(1469.8, 1127.9, 730.2, 64.7, 2.6, 8.0, 19.5)
  > data2006=c(1693.5, 1287.0, 832.9, 64.7, 2.6, 6.1, 20.5)
  > data2007=c(1986.5, 1510.7, 1045.7, 69.2, 2.8, 4.1, 19.2)
  > data2008=c(2310.6, 1753.3, 1353.6, 77.2, 2.3, 3.2, 16.8)
  > data2009=c(2534.1, 1973.0, 1437.9, 72.8, 2.6, 3.3, 17.4)
  > bank=data.frame(indicators, data2000, data2001, data2002, data2003, data2004, data2005, data2006, data2007,
  data2008, data2009)
R Graphics: Plot
  # Make data to be matrix and remove the first coloumb of bank
  bank_1=as.matrix(bank[,-1])

  # Graph the first row of bank_1 vector with 10 value




                                                                       2500
  plot(bank_1[1,])




                                                                       2000
                                                         bank_1[1, ]

                                                                       1500
                                                                       1000

                                                                              2   4           6   8   10

                                                                                      Index
R Graphics: Plot
  #Define bank_1[1,] with name total asset
  total_asset= bank_1[1,]
                                                                                          Total Assets (trillions of Rp)




                                                                               2500
  # Graph total_asset using blue points overlayed by a line
  plot(total_asset, type=“o”, col=“blue”)

  #Create a title with a red, blod/italic font




                                                                               2000
  title(main="Total Assets (trillions of Rp)", col.main="red",




                                                                 total_asset
  font.main=4)




                                                                               1500
                                                                               1000
                                                                                      2       4               6            8   10

                                                                                                      Index
R Graphics: Line Chart
  # Compute the largest y value used in the data (or we could just
  use range again)
                                                                                        Indicators of the Condition of Comercial Banks in Indonesia,2000-2009
  > max_y=max(bank_1)
                                                                                 2500

  # Define colors to be used for tree data                                       2250
                                                                                                Total Asset
                                                                                                Deposites
                                                                                                Credits
  > plot_warna=c("blue","red","green")                                           2000

                                                                                 1750
   # Graph bank_1 using y axis that ranges from 0 to max_y
                                                                                 1500
  # Turn off axes and annotations (axis labels) so we can




                                                                     Trillions
                                                                                 1250
  # specify them ourself
  > plot(bank_1[1,],                                                             1000

  type="o",col=plot_warna[1],ylim=c(0,max_y),axes=FALSE,                          750

  ann=FALSE)
                                                                                  500


                                                                                  250
   # Make x axis using 2000-2009 labels
                                                                                    0
  > axis(1, at=1:10, lab=c("2000", "2001", "2002", "2003", "2004",
  "2005", "2006", "2007", "2008", "2009"))                                               2000   2001          2002   2003   2004   2005   2006   2007   2008   2009

                                                                                                                               Years


  # Make y axis with horizontal labels that display ticks at
  # every 250 marks. 250*0:max_y is equivalent to c(250,500,750,…).
  > axis(2,las=1,at=250*0:max_y)
R Graphics: Line Chart
  # Create box around plot
  > box()                                                                          Indicators of the Condition of Comercial Banks in Indonesia,2000-2009


                                                                            2500

  # Graph Deposites with red dashed line and square points                  2250
                                                                                          Total Asset
                                                                                          Deposites
                                                                                          Credits

  > lines(bank_1[2,], type="o", pch=22, lty=2, col=plot_warna[2])           2000


                                                                            1750


  # Graph Credits with green dotted line and diamond points                 1500




                                                                Trillions
  > lines(bank_1[3,], type="o", pch=23, lty=3, col=plot_warna[3])           1250


                                                                            1000


   # Create a title with a red, bold/italic font                            750


                                                                            500
  > title(main="Indicators of the Condition of Comercial Banks in
  Indonesia,2000-2009", col.main="red", font.main=4)                        250


                                                                              0


                                                                                   2000    2001         2002   2003   2004   2005   2006   2007   2008   2009
  # Label the x and y axes with dark green text
                                                                                                                         Years
  > title(xlab="Years", col.lab=rgb(0,0.5,0))
  > title(ylab="Trillions", col.lab=rgb(0,0.5,0))
R Graphics: Line Chart
  # Create a legend at (2400)
  # (cex) and uses the same line colors and points used by                            Indicators of the Condition of Comercial Banks in Indonesia,2000-2009

  # the actual plots                                                           2500

  > legend(2400,c("Total Asset","Deposites","Credits"), cex=0.8,               2250
                                                                                             Total Asset
                                                                                             Deposites
                                                                                             Credits
  col=plot_warna, pch=21:23, lty=1:3)                                          2000


                                                                               1750


                                                                               1500




                                                                   Trillions
                                                                               1250


                                                                               1000


                                                                               750


                                                                               500


                                                                               250


                                                                                 0


                                                                                      2000    2001         2002   2003   2004   2005   2006   2007   2008   2009

                                                                                                                            Years
R Graphics: Boxplot
  # make graph with bank_1




                             2500
  > boxplot(bank_1)




                             2000
                             1500
                             1000
                             500
                             0
                                    data2000   data2001   data2002   data2003   data2004   data2005   data2006   data2007   data2008   data2009
Data 2000

R Graphics: Histogram




                                                                 4
  # Graph autos with adjacent bars using rainbow colors
  > hist(bank_1[,1], col="green", main="Data 2000",
  xlab="Trillions")




                                                                 3
                                                     Frequency

                                                                 2
                                                                 1
                                                                 0
                                                                     0   200   400      600       800   1000   1200

                                                                                      Trillions
R Graphics: Barplot
  # Graph autos with adjacent bars using rainbow colors
                                                                                    Indicators of the Condition of Comercial Banks in Indonesia,2000-2009
  > barplot(bank_1, main="Indicators of the Condition of




                                                                                   2500
  Comercial Banks in Indonesia,2000-2009",ylab="Trillions",                                 Total Assets (trillions of Rp)
                                                                                            Deposits(trillions of Rp)

  beside=TRUE, col=rainbow(7))                                                              Credit (trillions of Rp)
                                                                                            loan to Deposit Ratio-LDR (%)
                                                                                            Return on Assets-ROA (%)




                                                                                   2000
                                                                                            Non Performing Loans-NPL (%)
                                                                                            Capital Adequacy Ratio-CAR (%)


  # Place the legend at the top-left corner with no frame # using




                                                                                   1500
  rainbow colors




                                                                       Trillions
  > legend("topleft",c("Total Assets (trillions of




                                                                                   1000
  Rp)","Deposits(trillions of Rp)","Credit (trillions of Rp)", "loan
  to Deposit Ratio-LDR (%)","Return on Assets-ROA (%)", "Non
  Performing Loans-NPL (%)","Capital Adequacy Ratio-CAR




                                                                                   500
  (%)"),cex=0.8,bty="n", fill=rainbow(7))




                                                                                   0
                                                                                          data2000        data2002           data2004   data2006   data2008
R Graphics: Piechart                                                     Persentasi Total Suara

  # Define total suara vector with 4 values
  > total_suara=c(46442,101325,189858,128230)                                                                   1
                                                                                         21.8%
                                                                                                                2
  # Define some colors ideal for total suara                                                                    3
  > warna=rainbow(length(total_suara))                                                                          4
                                                                                                          10%
  # Calculate the percentage for candidate, rounded to one
  # decimal place
  > persentasi=round(total_suara/sum(total_suara)*100,1)         40.8%




  # Concatenate a '%' char after each value
  > persentasi=paste(persentasi, "%", sep="")
                                                                                                  27.5%

  # Create a pie chart with defined heading and custom colors #
  and labels
  > pie(total_suara, main="Persentasi Total Suara", col=warna,
  labels=persentasi, cex=0.8)

  # Create a legend at the right
  > legend("topright", c("1","2","3","4"),cex=1.7, fill=warna)
R Graphics: Dotchart                       1
                                               data2009
                                               data2008
                                               data2007
                                               data2006
                                                                    Indicators of the Condition of Comercial Banks in Indonesia,2000-2009




                                               data2005
  # Create a colored dotchart for bank_1       data2004
                                               data2003
                                               data2002
                                               data2001
                                               data2000

  with smaller labels                      2
                                               data2009
                                               data2008
                                               data2007
                                               data2006

  > dotchart(t(bank_1),
                                               data2005
                                               data2004
                                               data2003
                                               data2002
                                               data2001
                                               data2000

  color=rainbow(length(bank_1)),           3
                                               data2009
                                               data2008
                                               data2007

  main="Indicators of the Condition of         data2006
                                               data2005
                                               data2004
                                               data2003
                                               data2002

  Comercial Banks in Indonesia,2000-
                                               data2001
                                               data2000
                                           4
                                               data2009
                                               data2008

  2009",cex=0.8)                               data2007
                                               data2006
                                               data2005
                                               data2004
                                               data2003
                                               data2002
                                               data2001
                                               data2000
                                           5
                                               data2009
                                               data2008
                                               data2007
                                               data2006
                                               data2005
                                               data2004
                                               data2003
                                               data2002
                                               data2001
                                               data2000
                                           6
                                               data2009
                                               data2008
                                               data2007
                                               data2006
                                               data2005
                                               data2004
                                               data2003
                                               data2002
                                               data2001
                                               data2000
                                           7
                                               data2009
                                               data2008
                                               data2007
                                               data2006
                                               data2005
                                               data2004
                                               data2003
                                               data2002
                                               data2001
                                               data2000

                                                          0   500                     1000                       1500                       2000   2500

More Related Content

What's hot

Build It Fast: 5 Steps from Concept to Working Distributed System
Build It Fast: 5 Steps from Concept to Working Distributed System   Build It Fast: 5 Steps from Concept to Working Distributed System
Build It Fast: 5 Steps from Concept to Working Distributed System
Real-Time Innovations (RTI)
 
Object Recognition with Deformable Models
Object Recognition with Deformable ModelsObject Recognition with Deformable Models
Object Recognition with Deformable Models
zukun
 
07 2
07 207 2
07 2
a_b_g
 
Object Detection with Discrmininatively Trained Part based Models
Object Detection with Discrmininatively Trained Part based ModelsObject Detection with Discrmininatively Trained Part based Models
Object Detection with Discrmininatively Trained Part based Models
zukun
 
Spm Add Maths Formula List Form4
Spm Add Maths Formula List Form4Spm Add Maths Formula List Form4
Spm Add Maths Formula List Form4
guest76f49d
 
лекция райгородский слайды версия 1.1
лекция райгородский слайды версия 1.1лекция райгородский слайды версия 1.1
лекция райгородский слайды версия 1.1
csedays
 
Form 5 formulae and note
Form 5 formulae and noteForm 5 formulae and note
Form 5 formulae and note
smktsj2
 

What's hot (12)

Build It Fast: 5 Steps from Concept to Working Distributed System
Build It Fast: 5 Steps from Concept to Working Distributed System   Build It Fast: 5 Steps from Concept to Working Distributed System
Build It Fast: 5 Steps from Concept to Working Distributed System
 
Object Recognition with Deformable Models
Object Recognition with Deformable ModelsObject Recognition with Deformable Models
Object Recognition with Deformable Models
 
07 2
07 207 2
07 2
 
Object Detection with Discrmininatively Trained Part based Models
Object Detection with Discrmininatively Trained Part based ModelsObject Detection with Discrmininatively Trained Part based Models
Object Detection with Discrmininatively Trained Part based Models
 
Perm winter school 2014.01.31
Perm winter school 2014.01.31Perm winter school 2014.01.31
Perm winter school 2014.01.31
 
Spm Add Maths Formula List Form4
Spm Add Maths Formula List Form4Spm Add Maths Formula List Form4
Spm Add Maths Formula List Form4
 
Seminar psu 20.10.2013
Seminar psu 20.10.2013Seminar psu 20.10.2013
Seminar psu 20.10.2013
 
лекция райгородский слайды версия 1.1
лекция райгородский слайды версия 1.1лекция райгородский слайды версия 1.1
лекция райгородский слайды версия 1.1
 
Basic R
Basic RBasic R
Basic R
 
DIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationDIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image Manipulation
 
Form 5 formulae and note
Form 5 formulae and noteForm 5 formulae and note
Form 5 formulae and note
 
ADD MATHS SPM 1
ADD MATHS SPM 1ADD MATHS SPM 1
ADD MATHS SPM 1
 

Viewers also liked (11)

Data exploration and graphics with R
Data exploration and graphics with RData exploration and graphics with R
Data exploration and graphics with R
 
Graphics with r
Graphics with rGraphics with r
Graphics with r
 
Basic Graphics with R
Basic Graphics with RBasic Graphics with R
Basic Graphics with R
 
Adrenal agonist agents
Adrenal agonist agentsAdrenal agonist agents
Adrenal agonist agents
 
Overview Of Pharmacodynamics 04.15.09
Overview Of Pharmacodynamics 04.15.09Overview Of Pharmacodynamics 04.15.09
Overview Of Pharmacodynamics 04.15.09
 
Antagonist or agonist
Antagonist or agonistAntagonist or agonist
Antagonist or agonist
 
Concepts of agonist and antagonist receptors
Concepts of agonist and antagonist receptorsConcepts of agonist and antagonist receptors
Concepts of agonist and antagonist receptors
 
Serotonin agonist &antagonist
Serotonin agonist &antagonistSerotonin agonist &antagonist
Serotonin agonist &antagonist
 
Advanced R Graphics
Advanced R GraphicsAdvanced R Graphics
Advanced R Graphics
 
R Graphics
R GraphicsR Graphics
R Graphics
 
Pharmacodynamics (Mechanisn of drug action)
Pharmacodynamics (Mechanisn of drug action) Pharmacodynamics (Mechanisn of drug action)
Pharmacodynamics (Mechanisn of drug action)
 

Similar to R graphics by Novi Reandy Sasmita

CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
TUOS-Sam
 
Matlab intro
Matlab introMatlab intro
Matlab intro
fvijayami
 

Similar to R graphics by Novi Reandy Sasmita (13)

R scatter plots
R scatter plotsR scatter plots
R scatter plots
 
8. Vectors data frames
8. Vectors data frames8. Vectors data frames
8. Vectors data frames
 
Rambo
RamboRambo
Rambo
 
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
 
Formal Verification of Programming Languages
Formal Verification of Programming LanguagesFormal Verification of Programming Languages
Formal Verification of Programming Languages
 
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
NCCU: Statistics in the Criminal Justice System, R basics and Simulation - Pr...
 
Big Data Mining in Indian Economic Survey 2017
Big Data Mining in Indian Economic Survey 2017Big Data Mining in Indian Economic Survey 2017
Big Data Mining in Indian Economic Survey 2017
 
Om (Cont.)
Om (Cont.)Om (Cont.)
Om (Cont.)
 
Basic Analysis using R
Basic Analysis using RBasic Analysis using R
Basic Analysis using R
 
R Workshop for Beginners
R Workshop for BeginnersR Workshop for Beginners
R Workshop for Beginners
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
 
Matlab intro
Matlab introMatlab intro
Matlab intro
 
R tutorial for a windows environment
R tutorial for a windows environmentR tutorial for a windows environment
R tutorial for a windows environment
 

Recently uploaded

VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
dipikadinghjn ( Why You Choose Us? ) Escorts
 
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
dipikadinghjn ( Why You Choose Us? ) Escorts
 

Recently uploaded (20)

Mira Road Awesome 100% Independent Call Girls NUmber-9833754194-Dahisar Inter...
Mira Road Awesome 100% Independent Call Girls NUmber-9833754194-Dahisar Inter...Mira Road Awesome 100% Independent Call Girls NUmber-9833754194-Dahisar Inter...
Mira Road Awesome 100% Independent Call Girls NUmber-9833754194-Dahisar Inter...
 
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
Solution Manual for Principles of Corporate Finance 14th Edition by Richard B...
 
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
VIP Independent Call Girls in Bandra West 🌹 9920725232 ( Call Me ) Mumbai Esc...
 
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...Booking open Available Pune Call Girls Talegaon Dabhade  6297143586 Call Hot ...
Booking open Available Pune Call Girls Talegaon Dabhade 6297143586 Call Hot ...
 
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
(Vedika) Low Rate Call Girls in Pune Call Now 8250077686 Pune Escorts 24x7
 
Booking open Available Pune Call Girls Shivane 6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Shivane  6297143586 Call Hot Indian Gi...Booking open Available Pune Call Girls Shivane  6297143586 Call Hot Indian Gi...
Booking open Available Pune Call Girls Shivane 6297143586 Call Hot Indian Gi...
 
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
TEST BANK For Corporate Finance, 13th Edition By Stephen Ross, Randolph Weste...
 
Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.Gurley shaw Theory of Monetary Economics.
Gurley shaw Theory of Monetary Economics.
 
The Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdfThe Economic History of the U.S. Lecture 19.pdf
The Economic History of the U.S. Lecture 19.pdf
 
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
Mira Road Memorable Call Grls Number-9833754194-Bhayandar Speciallty Call Gir...
 
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
VIP Independent Call Girls in Andheri 🌹 9920725232 ( Call Me ) Mumbai Escorts...
 
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
02_Fabio Colombo_Accenture_MeetupDora&Cybersecurity.pptx
 
Vasai-Virar Fantastic Call Girls-9833754194-Call Girls MUmbai
Vasai-Virar Fantastic Call Girls-9833754194-Call Girls MUmbaiVasai-Virar Fantastic Call Girls-9833754194-Call Girls MUmbai
Vasai-Virar Fantastic Call Girls-9833754194-Call Girls MUmbai
 
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
Vip Call US 📞 7738631006 ✅Call Girls In Sakinaka ( Mumbai )
 
Stock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdfStock Market Brief Deck (Under Pressure).pdf
Stock Market Brief Deck (Under Pressure).pdf
 
Indore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdfIndore Real Estate Market Trends Report.pdf
Indore Real Estate Market Trends Report.pdf
 
WhatsApp 📞 Call : 9892124323 ✅Call Girls In Chembur ( Mumbai ) secure service
WhatsApp 📞 Call : 9892124323  ✅Call Girls In Chembur ( Mumbai ) secure serviceWhatsApp 📞 Call : 9892124323  ✅Call Girls In Chembur ( Mumbai ) secure service
WhatsApp 📞 Call : 9892124323 ✅Call Girls In Chembur ( Mumbai ) secure service
 
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
Solution Manual for Financial Accounting, 11th Edition by Robert Libby, Patri...
 
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
05_Annelore Lenoir_Docbyte_MeetupDora&Cybersecurity.pptx
 
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Wadgaon Sheri  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Wadgaon Sheri 6297143586 Call Hot Ind...
 

R graphics by Novi Reandy Sasmita

  • 1. R Graphics Practice and Theory Monday, March 26, 2012 Novi Reandy Sasmita novireandysasmita@gmail.com http://www.researchgate.net/profile/Novi_Sasmita
  • 3. R Graphics: Data > indicators=c("Total Assets (trillions of Rp)","Deposits(trillions of Rp)","Credit (trillions of Rp)", "loan to Deposit Ratio-LDR (%)","Return on Assets-ROA (%)", "Non Performing Loans-NPL (%)","Capital Adequacy Ratio-CAR (%)") > data2001=c(1099.7, 797.4, 358.6, 45.0, 1.4, 12.1, 20.5) > data2000=c(1030.5, 699.1, 320.5, 45.8, 0.9, 18.8, 12.7) > data2001=c(1099.7, 797.4, 358.6, 45.0, 1.4, 12.1, 20.5) > data2002=c(1112.2, 853.8, 410.3, 49.1, 1.9, 8.1, 22.5) > data2003=c(1196.2, 888.6, 477.2, 53.7, 2.5, 8.2, 19.4) > data2004=c(1272.3, 963.1, 596.1, 61.8, 3.5, 5.8, 19.4) > data2005=c(1469.8, 1127.9, 730.2, 64.7, 2.6, 8.0, 19.5) > data2006=c(1693.5, 1287.0, 832.9, 64.7, 2.6, 6.1, 20.5) > data2007=c(1986.5, 1510.7, 1045.7, 69.2, 2.8, 4.1, 19.2) > data2008=c(2310.6, 1753.3, 1353.6, 77.2, 2.3, 3.2, 16.8) > data2009=c(2534.1, 1973.0, 1437.9, 72.8, 2.6, 3.3, 17.4) > bank=data.frame(indicators, data2000, data2001, data2002, data2003, data2004, data2005, data2006, data2007, data2008, data2009)
  • 4. R Graphics: Plot # Make data to be matrix and remove the first coloumb of bank bank_1=as.matrix(bank[,-1]) # Graph the first row of bank_1 vector with 10 value 2500 plot(bank_1[1,]) 2000 bank_1[1, ] 1500 1000 2 4 6 8 10 Index
  • 5. R Graphics: Plot #Define bank_1[1,] with name total asset total_asset= bank_1[1,] Total Assets (trillions of Rp) 2500 # Graph total_asset using blue points overlayed by a line plot(total_asset, type=“o”, col=“blue”) #Create a title with a red, blod/italic font 2000 title(main="Total Assets (trillions of Rp)", col.main="red", total_asset font.main=4) 1500 1000 2 4 6 8 10 Index
  • 6. R Graphics: Line Chart # Compute the largest y value used in the data (or we could just use range again) Indicators of the Condition of Comercial Banks in Indonesia,2000-2009 > max_y=max(bank_1) 2500 # Define colors to be used for tree data 2250 Total Asset Deposites Credits > plot_warna=c("blue","red","green") 2000 1750 # Graph bank_1 using y axis that ranges from 0 to max_y 1500 # Turn off axes and annotations (axis labels) so we can Trillions 1250 # specify them ourself > plot(bank_1[1,], 1000 type="o",col=plot_warna[1],ylim=c(0,max_y),axes=FALSE, 750 ann=FALSE) 500 250 # Make x axis using 2000-2009 labels 0 > axis(1, at=1:10, lab=c("2000", "2001", "2002", "2003", "2004", "2005", "2006", "2007", "2008", "2009")) 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 Years # Make y axis with horizontal labels that display ticks at # every 250 marks. 250*0:max_y is equivalent to c(250,500,750,…). > axis(2,las=1,at=250*0:max_y)
  • 7. R Graphics: Line Chart # Create box around plot > box() Indicators of the Condition of Comercial Banks in Indonesia,2000-2009 2500 # Graph Deposites with red dashed line and square points 2250 Total Asset Deposites Credits > lines(bank_1[2,], type="o", pch=22, lty=2, col=plot_warna[2]) 2000 1750 # Graph Credits with green dotted line and diamond points 1500 Trillions > lines(bank_1[3,], type="o", pch=23, lty=3, col=plot_warna[3]) 1250 1000 # Create a title with a red, bold/italic font 750 500 > title(main="Indicators of the Condition of Comercial Banks in Indonesia,2000-2009", col.main="red", font.main=4) 250 0 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 # Label the x and y axes with dark green text Years > title(xlab="Years", col.lab=rgb(0,0.5,0)) > title(ylab="Trillions", col.lab=rgb(0,0.5,0))
  • 8. R Graphics: Line Chart # Create a legend at (2400) # (cex) and uses the same line colors and points used by Indicators of the Condition of Comercial Banks in Indonesia,2000-2009 # the actual plots 2500 > legend(2400,c("Total Asset","Deposites","Credits"), cex=0.8, 2250 Total Asset Deposites Credits col=plot_warna, pch=21:23, lty=1:3) 2000 1750 1500 Trillions 1250 1000 750 500 250 0 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 Years
  • 9. R Graphics: Boxplot # make graph with bank_1 2500 > boxplot(bank_1) 2000 1500 1000 500 0 data2000 data2001 data2002 data2003 data2004 data2005 data2006 data2007 data2008 data2009
  • 10. Data 2000 R Graphics: Histogram 4 # Graph autos with adjacent bars using rainbow colors > hist(bank_1[,1], col="green", main="Data 2000", xlab="Trillions") 3 Frequency 2 1 0 0 200 400 600 800 1000 1200 Trillions
  • 11. R Graphics: Barplot # Graph autos with adjacent bars using rainbow colors Indicators of the Condition of Comercial Banks in Indonesia,2000-2009 > barplot(bank_1, main="Indicators of the Condition of 2500 Comercial Banks in Indonesia,2000-2009",ylab="Trillions", Total Assets (trillions of Rp) Deposits(trillions of Rp) beside=TRUE, col=rainbow(7)) Credit (trillions of Rp) loan to Deposit Ratio-LDR (%) Return on Assets-ROA (%) 2000 Non Performing Loans-NPL (%) Capital Adequacy Ratio-CAR (%) # Place the legend at the top-left corner with no frame # using 1500 rainbow colors Trillions > legend("topleft",c("Total Assets (trillions of 1000 Rp)","Deposits(trillions of Rp)","Credit (trillions of Rp)", "loan to Deposit Ratio-LDR (%)","Return on Assets-ROA (%)", "Non Performing Loans-NPL (%)","Capital Adequacy Ratio-CAR 500 (%)"),cex=0.8,bty="n", fill=rainbow(7)) 0 data2000 data2002 data2004 data2006 data2008
  • 12.
  • 13. R Graphics: Piechart Persentasi Total Suara # Define total suara vector with 4 values > total_suara=c(46442,101325,189858,128230) 1 21.8% 2 # Define some colors ideal for total suara 3 > warna=rainbow(length(total_suara)) 4 10% # Calculate the percentage for candidate, rounded to one # decimal place > persentasi=round(total_suara/sum(total_suara)*100,1) 40.8% # Concatenate a '%' char after each value > persentasi=paste(persentasi, "%", sep="") 27.5% # Create a pie chart with defined heading and custom colors # and labels > pie(total_suara, main="Persentasi Total Suara", col=warna, labels=persentasi, cex=0.8) # Create a legend at the right > legend("topright", c("1","2","3","4"),cex=1.7, fill=warna)
  • 14. R Graphics: Dotchart 1 data2009 data2008 data2007 data2006 Indicators of the Condition of Comercial Banks in Indonesia,2000-2009 data2005 # Create a colored dotchart for bank_1 data2004 data2003 data2002 data2001 data2000 with smaller labels 2 data2009 data2008 data2007 data2006 > dotchart(t(bank_1), data2005 data2004 data2003 data2002 data2001 data2000 color=rainbow(length(bank_1)), 3 data2009 data2008 data2007 main="Indicators of the Condition of data2006 data2005 data2004 data2003 data2002 Comercial Banks in Indonesia,2000- data2001 data2000 4 data2009 data2008 2009",cex=0.8) data2007 data2006 data2005 data2004 data2003 data2002 data2001 data2000 5 data2009 data2008 data2007 data2006 data2005 data2004 data2003 data2002 data2001 data2000 6 data2009 data2008 data2007 data2006 data2005 data2004 data2003 data2002 data2001 data2000 7 data2009 data2008 data2007 data2006 data2005 data2004 data2003 data2002 data2001 data2000 0 500 1000 1500 2000 2500