library(ggplot2)
library(plotly)

First ggplot

Here is my first ggplot!

g <- ggplot(iris) +
  aes(Sepal.Length, Sepal.Width) +
  geom_point() +
  labs(x = "Sepal Length") +
  labs(y = "Sepal Width") +
  labs(title="The famous iris data") + 
  labs(subtitle="Data collected by Anderson, Edgar (1935)") +
  aes(color= Species) +
  theme_bw(base_size=16)
g

First plotly

Here is my first plotly! This is an interactive plot so try hovering it over and clicking. You may want to write message=F, warning=F as your R chunk option here to avoid some unwanted outputs.

plot_ly(iris, 
        x=~Sepal.Length, 
        y=~Sepal.Width, 
        color=~Species)

First ggplotly

Here is my first ggplotly! This is also an interactive plot. Remember that you cannot achieve this interactivity for pdf and doc. This is only designed for html output.

ggplotly(g)