-
Book Overview & Buying
-
Table Of Contents
R Data Science Essentials
By :
We will take a look at one interesting visualization using the googleVis package. First, we need to install the package and load it to the R environment using the following code:
install.packages("googleVis") library(googleVis)
We will now read a dataset that can be visualized using the googleVis package. From the worlddata dataset, we will consider the country and co2_emissions columns. The following code will read the dataset with all the columns and then select the required columns by specifying their names. We will then remove the rows with the NA values:
data <- read.csv("Data/worlddata.csv") newdata <- data[,c("country","co2_emissions")] newdata <- na.omit(newdata) head(newdata, 10)
The output of the preceding command is as follows:

We have now got the carbon dioxide emissions for all the countries. Let's try to plot this on the world map itself using the gvisGeoChart function. We need to pass the dataset that has to be plotted, the locationvar...
Change the font size
Change margin width
Change background colour