SlideShare a Scribd company logo
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
 
Perm winter school 2014.01.31
Perm winter school 2014.01.31Perm winter school 2014.01.31
Perm winter school 2014.01.31
Vyacheslav Arbuzov
 
Spm Add Maths Formula List Form4
Spm Add Maths Formula List Form4Spm Add Maths Formula List Form4
Spm Add Maths Formula List Form4
guest76f49d
 
Seminar psu 20.10.2013
Seminar psu 20.10.2013Seminar psu 20.10.2013
Seminar psu 20.10.2013
Vyacheslav Arbuzov
 
лекция райгородский слайды версия 1.1
лекция райгородский слайды версия 1.1лекция райгородский слайды версия 1.1
лекция райгородский слайды версия 1.1
csedays
 
Basic R
Basic RBasic R
DIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image ManipulationDIWE - Using Extensions and Image Manipulation
DIWE - Using Extensions and Image Manipulation
Rasan Samarasinghe
 
Form 5 formulae and note
Form 5 formulae and noteForm 5 formulae and note
Form 5 formulae and note
smktsj2
 
ADD MATHS SPM 1
ADD MATHS SPM 1ADD MATHS SPM 1
ADD MATHS SPM 1
njusohtan
 

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

Btp android-v1-0
Btp android-v1-0Btp android-v1-0
Btp android-v1-0
Steve Maher
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
beasiswa
 
Assistt 6.10 help desk bp v.1.2
Assistt   6.10 help desk bp v.1.2Assistt   6.10 help desk bp v.1.2
Assistt 6.10 help desk bp v.1.2
Istanbul, Turkey
 
Paalma
PaalmaPaalma
Paalma
eso310coll
 
10 lessons learned
10 lessons learned10 lessons learned
10 lessons learned
Istanbul, Turkey
 
Manish kumar project planning & control with 3.7 years of experience
Manish kumar project planning & control with 3.7 years of experienceManish kumar project planning & control with 3.7 years of experience
Manish kumar project planning & control with 3.7 years of experience
Manish Kumar PGP - NICMAR Pune
 

Viewers also liked (6)

Btp android-v1-0
Btp android-v1-0Btp android-v1-0
Btp android-v1-0
 
Basic operations by novi reandy sasmita
Basic operations by novi reandy sasmitaBasic operations by novi reandy sasmita
Basic operations by novi reandy sasmita
 
Assistt 6.10 help desk bp v.1.2
Assistt   6.10 help desk bp v.1.2Assistt   6.10 help desk bp v.1.2
Assistt 6.10 help desk bp v.1.2
 
Paalma
PaalmaPaalma
Paalma
 
10 lessons learned
10 lessons learned10 lessons learned
10 lessons learned
 
Manish kumar project planning & control with 3.7 years of experience
Manish kumar project planning & control with 3.7 years of experienceManish kumar project planning & control with 3.7 years of experience
Manish kumar project planning & control with 3.7 years of experience
 

Similar to R graphics by Novi Reandy Sasmita

R scatter plots
R scatter plotsR scatter plots
R scatter plots
Abhik Seal
 
8. Vectors data frames
8. Vectors data frames8. Vectors data frames
8. Vectors data frames
ExternalEvents
 
Rambo
RamboRambo
CIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & CourseworkCIV1900 Matlab - Plotting & Coursework
CIV1900 Matlab - Plotting & Coursework
TUOS-Sam
 
Formal Verification of Programming Languages
Formal Verification of Programming LanguagesFormal Verification of Programming Languages
Formal Verification of Programming Languages
Jason Reich
 
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...
The Statistical and Applied Mathematical Sciences Institute
 
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
Parth Khare
 
Om (Cont.)
Om (Cont.)Om (Cont.)
Om (Cont.)
Taku Fukushima
 
Basic Analysis using R
Basic Analysis using RBasic Analysis using R
Basic Analysis using R
Sankhya_Analytics
 
R Workshop for Beginners
R Workshop for BeginnersR Workshop for Beginners
R Workshop for Beginners
Metamarkets
 
6. R data structures
6. R data structures6. R data structures
6. R data structures
ExternalEvents
 
Matlab intro
Matlab introMatlab intro
Matlab intro
fvijayami
 
R tutorial for a windows environment
R tutorial for a windows environmentR tutorial for a windows environment
R tutorial for a windows environment
Yogendra Chaubey
 

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

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
mulvey2
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
AyyanKhan40
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
Colégio Santa Teresinha
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
Nicholas Montgomery
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
Kavitha Krishnan
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
PECB
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
simonomuemu
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
eBook.com.bd (প্রয়োজনীয় বাংলা বই)
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Dr. Vinod Kumar Kanvaria
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
National Information Standards Organization (NISO)
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
RitikBhardwaj56
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
Dr. Shivangi Singh Parihar
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
Celine George
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
Priyankaranawat4
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
Nicholas Montgomery
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
Dr. Mulla Adam Ali
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
Jean Carlos Nunes Paixão
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
heathfieldcps1
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Excellence Foundation for South Sudan
 

Recently uploaded (20)

C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptxC1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
C1 Rubenstein AP HuG xxxxxxxxxxxxxx.pptx
 
PIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf IslamabadPIMS Job Advertisement 2024.pdf Islamabad
PIMS Job Advertisement 2024.pdf Islamabad
 
MARY JANE WILSON, A “BOA MÃE” .
MARY JANE WILSON, A “BOA MÃE”           .MARY JANE WILSON, A “BOA MÃE”           .
MARY JANE WILSON, A “BOA MÃE” .
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
Film vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movieFilm vocab for eal 3 students: Australia the movie
Film vocab for eal 3 students: Australia the movie
 
Assessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptxAssessment and Planning in Educational technology.pptx
Assessment and Planning in Educational technology.pptx
 
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...
 
Smart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICTSmart-Money for SMC traders good time and ICT
Smart-Money for SMC traders good time and ICT
 
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdfবাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
বাংলাদেশ অর্থনৈতিক সমীক্ষা (Economic Review) ২০২৪ UJS App.pdf
 
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
Exploiting Artificial Intelligence for Empowering Researchers and Faculty, In...
 
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
Pollock and Snow "DEIA in the Scholarly Landscape, Session One: Setting Expec...
 
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...The simplified electron and muon model, Oscillating Spacetime: The Foundation...
The simplified electron and muon model, Oscillating Spacetime: The Foundation...
 
PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.PCOS corelations and management through Ayurveda.
PCOS corelations and management through Ayurveda.
 
How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17How to Fix the Import Error in the Odoo 17
How to Fix the Import Error in the Odoo 17
 
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdfANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
ANATOMY AND BIOMECHANICS OF HIP JOINT.pdf
 
writing about opinions about Australia the movie
writing about opinions about Australia the moviewriting about opinions about Australia the movie
writing about opinions about Australia the movie
 
Hindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdfHindi varnamala | hindi alphabet PPT.pdf
Hindi varnamala | hindi alphabet PPT.pdf
 
A Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdfA Independência da América Espanhola LAPBOOK.pdf
A Independência da América Espanhola LAPBOOK.pdf
 
The basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptxThe basics of sentences session 6pptx.pptx
The basics of sentences session 6pptx.pptx
 
Your Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective UpskillingYour Skill Boost Masterclass: Strategies for Effective Upskilling
Your Skill Boost Masterclass: Strategies for Effective Upskilling
 

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