Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to draw QQ Plots in Zeppelin using SparkR?

Highlighted

How to draw QQ Plots in Zeppelin using SparkR?

Super Collaborator

I am using Hortonworks Sandbox and able to create a dataframe using SparkR Livy interpreter of Zeppelin. Now I want to create a QQ plot, getting the following output in Zeppelin:

pdf 2

Please have a look at the qqplot-output.png. Do I have to import any external library to do this? Thanks in Advance

5 REPLIES 5
Highlighted

Re: How to draw QQ Plots in Zeppelin using SparkR?

Super Collaborator

Seems weird, just saw the graph in pdf called Rplots.pdf which got created under the home folder. Is this how it usually works? Is there any way to view it on Zeppelin UI?rplots.pdf

Highlighted

Re: How to draw QQ Plots in Zeppelin using SparkR?

Did you import ggplot2 library?

Highlighted

Re: How to draw QQ Plots in Zeppelin using SparkR?

Super Collaborator

Thanks a lot for the response, I tried installing ggplot2 for SparkR by:

%livy.sparkr

install.packages("ggplot2")

Gave me the following exception:

null device 1

Installing package into ‘/hadoop/yarn/local/usercache/livy/filecache/195/sparkr.zip’ (as ‘lib’ is unspecified)

Error in contrib.url(repos, type) : trying to use CRAN without setting a mirror Calls: install.packages -> grep -> contrib.url

Highlighted

Re: How to draw QQ Plots in Zeppelin using SparkR?

I have similar problem (HDP 2.5, Zeppelin Version 0.6.0.2.5.3.0-37) . ggplot2 is installed. When I try to make simple plot with ggplot2 then in Zeppelin then the result is :

null device 1

When I save plot as file ( ggsave(file='filename.png') ) it is stored under livy home directory and I can use it. Is it somehow possible to make Zeppelin to display plot?

Highlighted

Re: How to draw QQ Plots in Zeppelin using SparkR?

Explorer

Try this for getting the images from disk (http://stackoverflow.com/a/33411637)

# save file
ggsave(filename="/tmp/myplot.png", plot=p1)

library(knitr)
printImageURI<-function(file){
  uri=image_uri(file)
  file.remove(file)
  cat(sprintf("%%html <img width='700' src=\"%s\" />\n", uri))    
}
printImageURI("/tmp/myplot.png")
Don't have an account?
Coming from Hortonworks? Activate your account here