library(knitr)
library(rmarkdown)
suppressPackageStartupMessages(library(googleVis))
## Creating a generic function for 'toJSON' from package 'jsonlite' in package 'googleVis'
knitr::opts_chunk$set( message=FALSE, 
                       warning=FALSE)

base

http://www.statmethods.net/graphs/

plot(iris$Sepal.Length, iris$Petal.Length,        # x variable, y variable
     col = iris$Species,                          # colour by species
     pch = 16,                                    # type of point to use
     cex = 1,                                     # size of point to use
     xlab = "Sepal Length",                       # x axis label
     ylab = "Petal Length",                       # y axis label
     main = "Flower Characteristics in Iris")     # plot title

legend (x = 4.5, y = 7, legend = levels(iris$Species), col = c(1:3), pch = 16)

plot of chunk unnamed-chunk-2

ggplot2

http://ggplot2.org/

library(ggplot2)
gg <- ggplot(iris) +
      geom_point(aes(x=Sepal.Length, y=Petal.Length, color = Species)) +
      labs(title = "Flower Characteristics in Iris", x = "Sepal Length", y = "Petal Length")
gg

plot of chunk unnamed-chunk-3

ggvis

http://ggvis.rstudio.com/

#install.packages("ggvis", repos=c("http://rstudio.org/_packages", "http://cran.rstudio.com")) 
library(ggvis)
data(iris)

# hack for title from: http://stackoverflow.com/questions/25018598/add-a-plot-title-to-ggvis
add_title <- function(vis, ..., x_lab = "X units", title = "Plot Title") {
  add_axis(vis, "x", title = x_lab) %>% 
    add_axis("x", orient = "top", ticks = 0, title = title,
             properties = axis_props(
               axis = list(stroke = "white"),
               labels = list(fontSize = 0)
             ), ...)
}

p <- ggvis(iris, x = ~Sepal.Length, y = ~Petal.Length, fill = ~Species) %>% add_title(title = "Flower Characteristics in Iris", 
                                                                                      x_lab = "Sepal.Length")
layer_points(p)

googleVis

https://github.com/mages/googleVis#googlevis

library(googleVis)
op <- options(gvis.plot.tag = "chart")
options(op)

iris2 = iris[, c("Sepal.Length", "Petal.Length")]
i <- sapply(iris2, is.factor)
iris2[i] <- lapply(iris2[i], as.character)
flower <- gvisScatterChart(iris2, options = list(title = "Flower Characteristics in Iris"))
# plot(flower)
print(flower, "chart")

rCharts

http://rcharts.io/

library(rCharts)
names(iris) = gsub("\\.", "", names(iris))
rPlot(PetalLength ~ SepalLength , data = iris, color = 'Species', type = 'point')
## Error in myChart$copy(): could not find function "new"

plotly

https://plot.ly/r/

library(plotly)
data(iris)
plot_ly(iris, x = Sepal.Length, y = Petal.Length, color = Species, mode = "markers") %>% 
  layout(title = "Flower Characteristics in Iris")
## Error in html_screenshot(x): Please install the webshot package (if not on CRAN, try devtools::install_github("wch/webshot"))

ggplotly

https://plot.ly/ggplot2/

p <- ggplot(iris) +
      geom_point(aes(x=Sepal.Length, y=Petal.Length, color = Species)) +
      labs(title = "Flower Characteristics in Iris")

ggplotly(p)
## Error in html_screenshot(x): Please install the webshot package (if not on CRAN, try devtools::install_github("wch/webshot"))