Reader small image

You're reading from  Learning Spark SQL

Product typeBook
Published inSep 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781785888359
Edition1st Edition
Languages
Right arrow

Using SparkR for data visualization


The SparkR extension of the ggplot2 package, ggplot2.SparkR, allows SparkR users to build powerful visualizations.

In this section, we use various to visualize our data. Additionally, we also present examples of plotting of data on maps and visualizing graphs:

> csvPath <- "file:///Users/aurobindosarkar/Downloads/bank-additional/bank-additional-full.csv"

> df <- read.df(csvPath, "csv", header = "true", inferSchema = "true", na.strings = "NA", delimiter= ";")

> persist(df, "MEMORY_ONLY")

> require(ggplot2)

Note

Refer to the ggplot website for different options available to improve the displays of each of your plots at http://docs.ggplot2.org.

In the next step, we plot a basic bar that gives frequency counts for the different marital statuses in the data:

> ldf <- collect(select(df, df$age, df$duration, df$education, df$marital, df$job))

> g1 <- ggplot(ldf, aes(x = marital))

> g1 + geom_bar()

In the following example, we...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Learning Spark SQL
Published in: Sep 2017Publisher: PacktISBN-13: 9781785888359