Rpresent

Nguyen Tan Dat
5/12/2017

What is R?

new-talk

  • R provides a wide variety of statistical (linear and nonlinear modelling, time-series analysis, classification, clustering etc) and graphical techniques, and is highly extensible.

  • The S language is often the vehicle of choice for research in statistical methodology, and R provides an Open Source route to participation in that activity.

Step 1 R Base install

Step 2 Rstudios

Self-study R

install.packages("swirl")
library("swirl")
# Follow as instructed.

For more details on authoring R presentations

VD 1

plot of chunk unnamed-chunk-2plot of chunk unnamed-chunk-2

VD 2

plot of chunk unnamed-chunk-3plot of chunk unnamed-chunk-3

VD 3

plot of chunk unnamed-chunk-4plot of chunk unnamed-chunk-4

VD 4

plot of chunk unnamed-chunk-5plot of chunk unnamed-chunk-5

VD 5

plot of chunk unnamed-chunk-6plot of chunk unnamed-chunk-6

Facet_grid with GGPLOT2

plot of chunk unnamed-chunk-7plot of chunk unnamed-chunk-7

With Base

plot of chunk unnamed-chunk-8

Facet_grid with GGPLOT2

#Facet grid
sp <- ggplot(tips, aes(x=total_bill, y=tip/total_bill))
sp    + geom_point(shape =1)
sp + facet_grid(sex ~ day)+ geom_point(shape =1)

Facet_grid with GGPLOT2

plot of chunk unnamed-chunk-10plot of chunk unnamed-chunk-10

Facet_grid With Base

par(mfrow=c(2,4))
days <- c("Thur", "Fri", "Sat", "Sun")
sexes <- unique(tips$sex)
for (i in 1:length(sexes)) {
  for (j in 1:length(days)) {
    currdata <- tips[tips$day == days[j] & tips$sex == sexes[i],]
    plot(currdata$total_bill, currdata$tip/currdata$total_bill,
        main=paste(days[j], sexes[i], sep=", "), ylim=c(0,0.7), las=1)
  }
}

Facet_grid With Base

plot of chunk unnamed-chunk-12

Other example A

plot of chunk unnamed-chunk-13

B

plot of chunk unnamed-chunk-14plot of chunk unnamed-chunk-14

C

plot of chunk unnamed-chunk-15plot of chunk unnamed-chunk-15

D

plot of chunk unnamed-chunk-16plot of chunk unnamed-chunk-16

HISTOGRAM

plot of chunk unnamed-chunk-17plot of chunk unnamed-chunk-17

COLOR

plot of chunk unnamed-chunk-18plot of chunk unnamed-chunk-18

TEXT LABEL

plot of chunk unnamed-chunk-19plot of chunk unnamed-chunk-19plot of chunk unnamed-chunk-19

BOXPLOT

plot of chunk unnamed-chunk-20plot of chunk unnamed-chunk-20

CONNECTION MAP

plot of chunk unnamed-chunk-21

DENSITY

plot of chunk unnamed-chunk-22

MARGINAL HISTOGRAM FOR GGPLOT2

                   mpg cyl disp  hp drat    wt  qsec vs am gear carb
Mazda RX4         21.0   6  160 110 3.90 2.620 16.46  0  1    4    4
Mazda RX4 Wag     21.0   6  160 110 3.90 2.875 17.02  0  1    4    4
Datsun 710        22.8   4  108  93 3.85 2.320 18.61  1  1    4    1
Hornet 4 Drive    21.4   6  258 110 3.08 3.215 19.44  1  0    3    1
Hornet Sportabout 18.7   8  360 175 3.15 3.440 17.02  0  0    3    2
Valiant           18.1   6  225 105 2.76 3.460 20.22  1  0    3    1

plot of chunk unnamed-chunk-24

ANNOTATION

plot of chunk unnamed-chunk-25

SPYWEB

plot of chunk unnamed-chunk-26plot of chunk unnamed-chunk-26

RADAR 1

plot of chunk unnamed-chunk-27plot of chunk unnamed-chunk-27

RADAR 2

plot of chunk unnamed-chunk-28

CIRCULAR BARPLOT

plot of chunk unnamed-chunk-29plot of chunk unnamed-chunk-29

STACK PLOT

plot of chunk unnamed-chunk-30plot of chunk unnamed-chunk-30plot of chunk unnamed-chunk-30

TREEMAP

plot of chunk unnamed-chunk-31

TREEMAP

plot of chunk unnamed-chunk-32

TREEMAP

plot of chunk unnamed-chunk-33

Slide With Plotly

Advantages:

  • It lets you create interactive visualizations built using D3.js without even having to know D3.js.
  • It provides compatibility with number of different languages/ tools like R, Python, MATLAB, Perl, Julia, Arduino.
  • Using plotly, interactive plots can easily be shared online with multiple people.
  • Plotly can also be used by people with no technical background for creating interactive plots by uploading the data and using plotly GUI. Plotly is compatible with ggplots in R and Python.
  • It allows to embed interactive plots in projects or websites using iframes or html.
  • The syntax for creating interactive plots using plotly is very simple as well.

Disadvantages:

  • The plots made using plotly community version are always public and can be viewed by anyone.
  • For plotly community version, there is an upper limit on the API calls per day.
  • There are also limited number of color Palettes available in community version which acts as an upper bound on the coloring options.

Art

plot of chunk unnamed-chunk-35plot of chunk unnamed-chunk-35