Using SparkR with Zeppelin

The latest Hortonworks Sandbox provides a preconfigured Zeppelin service, which can be used to work with SparkR scripts. For other virtual machines such as Cloudera or MapR, we need to manually install and configure Zeppelin. Follow the steps created in the The manual method section under the Installing Apache Zeppelin section in Chapter 6, Notebooks and Dataflows with Spark and Hadoop.

Open the Zeppelin UI at http://localhost:9999. Create a new notebook and enter the following SparkR code in a paragraph. In the next paragraph, query the data using SQL. DataFrames returned from SparkR will be displayed using Zeppelin's built-in interactive visualizations, as shown in the following charts (bar plot and pie chart).

If you get an error such as interpreter not found, click on the Interpreter binding icon in the top-right corner of the notebook, and then click on Save to resolve the issue:

%r
data(mtcars)
cars <- createDataFrame(mtcars)
createOrReplaceTempView(cars, "carstable")

The output of SparkR can be visualized with the following Zeppelin in-built visualizations:

Method 1: Bar plot:

Using SparkR with Zeppelin

Figure 10.10: Zeppelin SparkR bar plot visualization

Method 2: Pie chart:

Using SparkR with Zeppelin

Figure 10.11: Zeppelin SparkR pie chart

R visualizations can be leveraged on Zeppelin notebooks as well.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.17.157.6