A simple line plot
Line plots are simply lines connecting all the x and y dots. They are very easy to interpret and are widely used to display an upward or downward trend in data. In this recipe, we will use the googleVis
package and create an interactive R line plot. We will learn how we can emphasize on certain variables in our data. The following line plot shows fertility rate:
Getting ready
We will use the googleVis
package to generate a line plot.
How to do it…
In order to construct a line chart, we will install and load the googleVis
package in R. We would also import the fertility data using the read.csv()
function:
install.packages("googleVis") library(googleVis) frt = read.csv("fertility.csv", header = TRUE, sep =",")
The fertility data is downloaded from the OECD website. We can construct our line object using the gvisLineChart()
function:
gvisLineChart(frt, xvar = "Year", yvar=c("Australia","Austria","Belgium","Canada","Chile","OECD34"), options = list( width = 1100...